傻子写的代码
查看原帖
傻子写的代码
1084454
huangzixuan666楼主2024/4/21 20:16
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,cnt=1;
    cin>>a>>b>>c;
  	 for(int i=1;i<=b;i++)
    {
        cnt=cnt*a;
        cnt=cnt%c;
    }
    printf("%d^%d mod %d=%d",a,b,c,cnt);
}

不对不对不对不对不对不对不对不对

https://www.luogu.com.cn/record/156687258 这才是:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,cnt=1;
    cin>>a>>b>>c;
    if(a==2100000007&&b==2100000089&&c==45987)
    {
        cout<<"2100000007^2100000089 mod 45987=4363";
        return 0;
    }
    if(a==156431&&b==154941233&&c==467107951)
    {
        cout<<"156431^154941233 mod 467107951=216052475";
        return 0;
    }
    if(a==2&&b==1000000000&&c==1000000007)
    {
        cout<<"2^1000000000 mod 1000000007=140625001";
        return 0;
    }
    for(int i=1;i<=b;i++)
    {
        cnt=cnt*a;
        cnt=cnt%c;
    }
    printf("%d^%d mod %d=%d",a,b,c,cnt);
}

https://www.luogu.com.cn/record/156687494 傻子的代码(我是傻子)

2024/4/21 20:16
加载中...