UESTC--1548

题目:Easy math

原题链接:http://acm.uestc.edu.cn/problem.php?pid=1548

分析:费马小定理的应用。

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<cmath>
 4 #include<algorithm>
 5 using namespace std;
 6 #define LL long long
 7 const LL mod=1000000007;
 8 LL pow_mod(LL a,LL b,LL m)
 9 {
10     if(b==0)return 1%m;
11     LL temp=pow_mod(a,b>>1,m);
12     temp=temp*temp%m;
13     if(b&1)temp=temp*a%m;
14     return temp;
15 }
16 int main()
17 {
18     LL a,b,c;
19     while(~scanf("%lld%lld%lld",&a,&b,&c))
20     {
21         LL temp=pow_mod(b,c,mod-1);
22         LL ans=pow_mod(a,temp,mod);
23         printf("%lld\n",ans);
24     }
25     return 0;
26 }
View Code

 

posted @ 2013-09-17 16:49  EtheGreat  阅读(142)  评论(0编辑  收藏  举报