HDOJ 2035 人见人爱A^B

 1 // HDOJ 2035
2 // @author: bos
3 // @date: 2012.2.6
4 //求A^B的最后三位数
5 #include <stdio.h>
6 int main()
7 {
8 int a, b;
9 int temp;
10 int i;
11 while((scanf("%d%d", &a, &b)!= EOF)&& (a|| b!= 0))
12 {
13 int result= 1;
14 temp= a% 1000;
15 i= b;
16 while(i--)
17 {
18 result= (result* temp)% 1000;
19 }
20 printf("%d\n", result);
21
22
23 }
24 return 0;
25
26 }

2012-02-06 16:13:56

posted @ 2012-02-06 16:15  ibos  阅读(207)  评论(0编辑  收藏  举报