Information
- ID
- 196
- Time
- 1000ms
- Memory
- 512MiB
- Difficulty
- 6
- Tags
- # Submissions
- 17
- Accepted
- 12
- Uploaded By
快速幂模板。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,m,ans=1;
int main(){
scanf("%lld%lld%lld",&a,&b,&m);
while(b){
if(b%2) ans=ans*a%m;
a=a*a%m;
b/=2;
}
printf("%lld",ans);
}
By signing up a HFOJ universal account, you can submit code and join discussions in all online judging services provided by us.