为啥错了
查看原帖
为啥错了
642434
__DayLight__楼主2023/9/27 13:53

注释的那行数据错了,错误输出是2547862^87432 mod 44169=23197

#include<bits/stdc++.h>
using namespace std;
long long a,n,mod;
int quick_pow(int a,int n)
{
    if(n==0)return 1;
    else if(n%2==1)return quick_pow(a,n-1)*a%mod;
    else
    {
        int temp=quick_pow(a,n/2);
        return temp*temp%mod;
    }
}
int main(){
	cin>>a>>n>>mod;
	printf("%lld^%lld mod %lld=%lld",a,n,mod,quick_pow(a,n)%mod);
	return 0;
}
//输入2547862 87432 44169 
//正确输出2547862^87432 mod 44169=31108
2023/9/27 13:53
加载中...