Problem : 2035 ( 人见人爱A^B ) Judge Status : Accepted RunId : 5683762 Language : C++ Author : ssun Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta #include<iostream> using namespace std; int pow_mod(int a,int b) { if(b==1) return a; __int64 x = pow_mod(a,b/2); __int64 ans = x * x % 1000; if(b%2==1) ans = ans * a % 1000; return (int)ans; } int main() { int a,b,i; while(scanf("%d%d",&a,&b)!=EOF) { if(a==0 && b==0) break; printf("%d\n",pow_mod(a,b)); } return 0; }