95分求助,#16没过
查看原帖
95分求助,#16没过
876088
MRevolution楼主2023/6/2 20:25

先上代码:

#include<bits/stdc++.h>
using namespace std;
bool check(int p,int q,int r,int ide){
    long long cnt=0,temp=0,temp1=0;
    long long i=0;
    while(r!=0){
        cnt+=((r%10)*pow(ide,i++));
        r/=10;
    }i=0;
    while(p!=0){
        temp+=((p%10)*pow(ide,i++));
        p/=10;
    }i=0;
    while(q!=0){
        temp1+=((q%10)*pow(ide,i++));
        q/=10;
    }
    if(cnt==temp1*temp)return 1;
    return 0;
}
int main(int argc, char const *argv[])
{
    int p,q,r;
    cin>>p>>q>>r;
    for(short ide=2;ide<=16;ide++){
        if(check(p,q,r,ide)==1){
            cout<<ide;
            return 0;
        }
    }
    cout<<"0";
    return 0;
}

想法就是在函数里面全判了

但是本蒟蒻看了讨论版里的帖子,但是还是解决不了

甚至还跌到了75(汗

大佬求助!!!!!!!!

2023/6/2 20:25
加载中...