Cute A ^ B
Subject description:
A ^ B integer seek the last three digits of the representation.
Description: A ^ B is the meaning of "A, B power"Input
Input data comprising a plurality of test cases, one row for each instance, two positive integers A and B (1 <= A, B <= 10000), if A = 0, B = 0, it means the end of the input data without processing.
Output
For each test case, output a final three A ^ B integer representation, each output per line.
Sample Input
2 3 12 6 6789 10000 0 0Sample Output
8 984 1
By the answer:
#include<stdio.h>
int main(){
int a,b,i,mul;
while(scanf("%d %d",&a,&b)!=EOF){
if(a==0&&b==0)break; //如果A=0, B=0,则表示输入数据的结束,不做处理
mul=1;
for(i=0;i<b;i++){ //关键!不能直接一次求幂
mul=mul*a%1000;
}
printf("%d\n",mul);
}
return 0;
}