AcWing 89. a^b

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
ll a,b,p;
ll qpow(ll a,ll b,ll p)
{
ll res=1;
while(b)
{
if(b&1)
res=(res*a)%p;
a=(a*a)%p;
b>>=1;
}
return res%p;
}
int main()
{
cin>>a>>b>>p;
cout<<qpow(a,b,p)<<endl;
return 0;
}
Donate
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2022-2024 CPY
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信