题目描述
Description
著名生物学家F博士发现了一种单细胞生物。
它长得像蚯蚓,分裂速度极快(每分钟一次),分裂也像蚯蚓一样,断成两段,再长成。
它很好斗,只要q只聚集在一起,就会q只一群打起来,当然都会打死。
假设一开始有1只,求a分钟后有多少只单细胞蚯蚓?
数据范围及提示
Data Size & Hint
对于50%数据,A<=20,Q<=100.
对于全部数据,A<=2*10^9,Q<=10^8.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 40000 + 20;
const int moder = 1e9 + 7;
const int K = 256;
ll mod_pow(ll x,ll n,ll mod)
{
ll res = 1;
while(n > 0)
{
if(n & 1) res = (res * x) % mod;
x = (x * x) % mod;
n >>= 1;
}
return res;
}
int main()
{
ll b,p,k;
scanf("%lld%lld",&p,&k);
cout << mod_pow(2,p,k);
return 0;
}
嘿嘿,稍微想一下就是快速幂裸题。
转载于:https://www.cnblogs.com/cunyusup/p/8401816.html