36分求助
查看原帖
36分求助
160506
言舟楼主2021/9/12 11:02

实在看不出来有哪些问题了

# include <iostream>
# include <cstdio>

using namespace std;
long long a,b,p,i,j,k;
int main () {
//    freopen("P1226_4.in","r",stdin);
    cin >> a >> b >> p;
    printf("%lld^%lld mod %lld=",a,b,p);
    k=a;
    while ( b>1 ) {
            a=((a%p)*(a%p))%p;
        if ( b%2==1 ) {
            a=a*k%p;
        }
        b=b>>1;
//        printf("b:%lld  %lld\n",b,a);
    }
    a%=p;
    printf("%lld",a);

    return 0;
}
2021/9/12 11:02
加载中...