标签:cst pre mes print names type while 快速幂 string
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; ll ksm(ll a, ll b, ll c) { ll ans=1; a=a%c; while(b>0) { if(b%2==1) ans=(ans*a)%c; b=b/2; a=(a*a)%c; } return ans; } int main() { ll a,b,c; scanf("%lld %lld %lld",&a,&b,&c); printf("%lld\n",ksm(a,b,c)); return 0; }
标签:cst pre mes print names type while 快速幂 string
原文地址:https://www.cnblogs.com/xiao-xue-di/p/9454321.html