二分幂


#include<stdio.h>
#include<stdlib.h>
#define N 1000;
int main(){
long  int  a,b,ans;
while(scanf("%d%d",&a,&b)!=EOF){
if(0==a&&0==b){break;}
     ans=1;
while(b!=0){
if(1==b%2){
ans*=a;
ans%=N;
}
b/=2;
a*=a;
a%=N;
}
printf("%lld",ans);
}
system("pause");
return 0;
}


相关文章:

  • 2021-08-12
  • 2022-12-23
  • 2021-05-28
  • 2021-10-23
  • 2022-12-23
  • 2022-01-30
  • 2021-12-19
  • 2021-08-17
猜你喜欢
  • 2022-12-23
  • 2021-11-19
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
相关资源
相似解决方案