做的一个题,是关于b^e%m的大运算 其中数据会比较大
题就不具体写了
把算法帖出来吧
#include <stdio.h>
int main()
{
long b;
long e;
long m;
long a;
while(scanf("%ld%ld%ld",&b,&e,&m)!=EOF)
{
a=1;
if(b==0||m==1){printf("0/n");continue;}
if(e==0){printf("1/n");continue;}
while(e)
{
if(e%2) a=(a*b)%m;
b=((b%m)*(b%m))%m;
e/=2;
}
printf("%ld/n",a);
}
return 0;
}
878

被折叠的 条评论
为什么被折叠?



