evan

For the lasting love

导航

(a^b) mod c

1 #include <stdio.h>
2
3  int main ()
4 {
5 int res=1,i=0;
6 int a=0,b=0,c=0;
7
8 // (a^b)%c
9 while (scanf ("%d%d%d",&a,&b,&c)!=EOF)
10 {
11 res=1;
12
13 for (i=0; i<b&&res; i++)
14 res = (res*a)%c;
15
16 printf ("%d\n",res);
17 }
18
19 return 0;
20 }

 

posted on 2010-06-22 12:32  evander  阅读(298)  评论(0编辑  收藏  举报