HDU 2035 人见人爱A^B

题目链接http://acm.hdu.edu.cn/showproblem.php?pid=2035

快速幂取模板

View Code
 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 int main()
 4 {
 5     int a,b,cj,jg,i;
 6     while(~scanf("%d %d",&a,&b))
 7     {
 8 
 9         if(a==0&&b==0)
10         break;
11         if(b==0)
12         {
13             printf("1\n");
14         }
15         else
16         {
17             cj=1;
18             for(i=1;i<=b;i++)
19             {cj=cj*a;
20             cj=cj%1000;
21             }
22            
23         }
24        printf("%d\n",cj);
25     }
26     return 0;
27 }
posted @ 2012-08-03 20:32  时光旅行的懒猫  阅读(256)  评论(0编辑  收藏  举报