hdu_5793_A Boring Question(打表找规律)
题目链接:hdu_5793_A Boring Question
题意:
自己看吧,说不清楚了。
题解:
打表找规律
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<cstdio> 2 typedef long long ll; 3 4 const int mod=1e9+7; 5 ll pow(ll a,ll b) 6 { 7 ll an=1; 8 while(b){ 9 if(b&1)an=(an*a)%mod; 10 b>>=1,a=(a*a)%mod; 11 } 12 return an; 13 } 14 15 int main(){ 16 int t,n,m; 17 scanf("%d",&t); 18 while(t--) 19 { 20 scanf("%d%d",&n,&m); 21 printf("%lld\n",((pow(m,n+1)-1+mod)*pow(m-1,mod-2))%mod); 22 } 23 return 0; 24 }