题目:求A^B的最后三位数表示的整数
#include<stdio.h>
int main()
{
int a, b;
while (scanf("%d%d", &a, &b) != EOF)
{
int ans = 1;
if (a == 0 && b == 0)
break;
while (b != 0)
{
if (b % 2 == 1)
{
ans *= a;
ans = ans % 1000;
}
b = b / 2;
a = a * a;
a = a % 1000;
}
printf("%d\n", ans);
}
return 0;
}