杭电OJ2035
这题数据范围太大很容易超过longlong类型的表示范围,所以在每次处理前取前三位即可
#include<cstdio>
using namespace std;
int main(){
int n,m;
while(scanf("%d %d",&n,&m)!=EOF){
if(n==0&&m==0){
break;
}
long long temp =n%1000;
for(int i = 0 ;i<m-1;i++){
temp =temp%1000;
temp *= (n%1000);
}
if(m==0){
printf("1");
}else{
printf("%d",(temp%1000/100)*100+(temp%100/10)*10+temp%10);
}
printf("\n");
}
return 0;
}