90分求调,必回关
查看原帖
90分求调,必回关
1501649
lloydsanchez楼主2025/1/17 10:45
#include<bits/stdc++.h>
using namespace std;
int p,q,r,maxj=-1;
int jz(int j,int num){
    int ans=0,t=0;
    while(num!=0){
        ans+=(num%10)*pow(j,t);
        // cout<<num<<endl;
        t++;
        num/=10;
    }
    return ans;
}
void tst(int x){
    int ans=0;
    while(x!=0){
        ans=x%10;
        if(ans>maxj){
            maxj=ans;
        }
        x/=10;
    }
}
int main()
{
    cin>>p>>q>>r;
    tst(p);tst(q);tst(r);
    // cout<<maxj;
    // jz(13,r);
    for(int i=2;i<=16;i++){
        int a,b,c;
        // for(int j=2;j<)
        // cout<<i<<endl;
        a = jz(i,p);
        b = jz(i,q);
        c = jz(i,r);
        // cout<<i<<" "<<a<<" "<<q<<" "<<r<<endl;
        if(a*b==c&&maxj<i){
            cout<<i;
            // cout<<a<<" "<<b<<" "<<c;            
            return 0;
        }
    }
    // cout<<maxj;
    cout<<0;
    return 0;
}

2025/1/17 10:45
加载中...