题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=2035
人见人爱A^B
算法分析:用循环来求A的B次方,再对1000取余保证三位数。
我的ac代码:
#include<stdio.h> int main() { int A, B; while (~scanf("%d %d", &A, &B) && A!=0||B!=0) { int res=1; for(int i=0;i<B;i++){ res=res*A%1000; } printf("%d\n",res); } return 0; }