您的位置:首页 > 其它

51nod 1046 A^B Mod C

2016-09-09 20:29 183 查看
快速幂

a^b %c = ( a%c * b%c)%c

#include <iostream>
#include <stdio.h>
using namespace std;
long long sum=0;
void quicksort(int a,int b,int c)
{
long long z=a;
long long ans=1;
while(b!=0)
{
if(b&1)
ans*=z;
z=z*z;
z%=c;
ans%=c;
b>>=1;
}
cout<<ans<<endl;

}

int main()
{
int a,b,c;
cin>>a>>b>>c;
quicksort(a,b,c);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: