码迷,mamicode.com
首页 > 其他好文 > 详细

【数论】【快速幂】CODEVS 2952 细胞分裂 2

时间:2014-10-27 09:14:04      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   sp   div   on   log   amp   

裸快速幂取模,背诵模板用。

 1 #include<cstdio>
 2 using namespace std;
 3 typedef long long LL;
 4 LL n=1,m,q;
 5 LL Quick_Pow(LL a,LL p,LL MOD)
 6 {
 7     if(!p) return 1;
 8     LL ans=Quick_Pow(a,p>>1,MOD);
 9     ans=ans*ans%MOD;
10     if((p&1)==1) ans=ans*a%MOD;
11     return ans;
12 }
13 int main()
14 {
15     scanf("%lld%lld",&m,&q);
16     printf("%lld\n",Quick_Pow(2,m,q));
17     return 0;
18 }

 

【数论】【快速幂】CODEVS 2952 细胞分裂 2

标签:style   blog   color   io   sp   div   on   log   amp   

原文地址:http://www.cnblogs.com/autsky-jadek/p/4053427.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!