#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll mod=1e9+7;
ll qpow2(ll a,ll b,ll p){
ll base=a;
ll res=1;
while(b){
if(b&1)res=(res*base)%p;
base=(base*base)%p;
b>>=1;
}
return res%p;
}
ll inv(ll a,ll b)
{
return (a*qpow2(b,mod-2,mod))%mod;
}
int main(){
ll w,d;cin>>w>>d;
ll p[w+10],a[w+10];
ll n=1;
ll sum=1;ll ans=1;
for(ll i=1;i<=w;i++){
cin>>p[i]>>a[i];
ll q=qpow2(p[i],d,mod);
if(q==1)sum=(a[i]+1)%mod;
else{
sum=inv((qpow2(q,a[i]+1,mod)-1),(q-1));
}
ans=(ans*sum)%mod;
}
cout<<ans<<endl;
}
b小红的约数(牛客)
2024-07-06 07:20:40