题解:
一次抛到面为x的概率为1/n,那么m次概率就是。
那么输的概率就是。把左边的化为分子的形式。
即可得出式子
(temp-1)*qp(temp,mod-2)
代码:
/*Keep on going Never give up*/ //#pragma GCC optimize(3,"Ofast","inline") #include<bits/stdc++.h> #define int long long #define endl '\n' #define Accepted 0 #define AK main() #define I_can signed using namespace std; const int maxn =2e5+10; const int MaxN = 0x3f3f3f3f; const int MinN = 0xc0c0c00c; typedef long long ll; const int inf=0x3f3f3f3f; const ll mod=1e9+7; using namespace std; int qp(int a,int b){ int res=1; while(b){ if(b&1) res=res*a%mod; a=a*a%mod; b>>=1; } return res; } I_can AK{ ios::sync_with_stdio(false); int t; cin>>t; while(t--){ int x,y; cin>>x>>y; int temp=qp(x,y); cout<<(temp-1)*qp(temp,mod-2)%mod<<endl; } return 0; }