比赛 位运算及及其应用题单 评测结果 AAAAAAAAAA
题目名称 取余运算 最终得分 100
用户昵称 李金泽 运行时间 0.013 s
代码语言 C++ 内存使用 1.54 MiB
提交时间 2025-01-25 11:12:35
显示代码纯文本
#include<cstdio>
#define ll long long
using namespace std;
int n;ll a,p;
ll fp()
{
    ll ans=1;
    while(n)
    {
        if(n&1)ans=ans*a%p;
        a=a*a%p;
        n>>=1;
    }
    return ans;
}
int main(){
    freopen("dmod.in","r",stdin);freopen("dmod.out","w",stdout);
    scanf("%lld%d%lld",&a,&n,&p);
    printf("%lld",fp());
    return 0;
}