题目链接http://poj.org/problem?id1995
参考http://www.cnblogs.com/PegasusWang/archive/2013/03/13/2958150.html
解题报告
#include #include #include using namespace std;///a^b%c?int PowerMod(int a,int b,int c){int ans1;aa%c;while(b>0){if(b%21)ans(ans*a)%c;bb/2;a(a*a)%c;}return ans;}int mod_exp(int a,int b,int c){int ans1;aa%c;while(b){if(bans*a%c;aa*a%c;bb>>1;}return ans;}int main(){int T;cin >> T;while (T--){int ans0;int mod;int n;scanf("%d%d",for(int i0;i
快速幂取模
1、
int ans1;for(int i1;i2、
int ans1;aa%c;for(int i1;i3、
int ans1;aa%c;for(int i1;i4、
int ans1;aa%c;if(b%21)ans(ans*a)%c;int k(a*a)%c;for(int i1;i5、
int PowerMod(int a,int b,int c){int ans1;aa%c;while(b>0){if(b%21)ans(ans*a)%c;bb/2;a(a*a)%c;}return ans;}
6、
int mod_exp(int a,int b,int c){int ans1;aa%c;while(b){if(bans*a%c;aa*a%c;bb>>1;}return ans;}
转:https://www.cnblogs.com/TreeDream/p/5394687.html