a的b次方模c
View Code
int fn2(int a,int b,int c){ int result=1; int x=a%c; while(b>0){ if(b%2){ result=(result*x)%c; } x=(x*x)%c; b/=2; } return result; }
View Code
int fn2(int a,int b,int c){ int result=1; int x=a%c; while(b>0){ if(b%2){ result=(result*x)%c; } x=(x*x)%c; b/=2; } return result; }