全WA
查看原帖
全WA
660243
shenmeyebuhui楼主2022/7/30 11:51
include<cmath>
include<cstdio>
include<stdio.h>
include<cstring>
include<iostream>
include<algorithm>
using namespace std;

long long ksm(long long a,long long b,long long p) {

long long t;
if(a==0)
{
    return 0%p;
}
else if(b==0)
{
    return 1%p;
}
else
{
    if(b%2==0)
    {
        t=ksm(a,b/2,p);
        return t*t%p;
    }
    else
    {
        return t*t*a%p;
    }
}
}

int main()

{

long long a,b,p;

scanf("%lld%lld%lld",&a,&b,&p);

printf("%lld^%lld mod %lld=%lld",a,b,p,ksm(a,b,p));

return 0;

}
2022/7/30 11:51
加载中...