85分(悬关)
查看原帖
85分(悬关)
1267066
yi18600361898楼主2024/6/20 21:05

代码:

#include <bits/stdc++.h>
using namespace std;
int toten(int n,int i){
    string s=to_string(n);
    int he=0,j=0;
    for(int k=0;k<s.length();k++) s[k]=s[k]-'0'+0;
    for(int k=s.length()-1;k>=0;k--) he+=s[k]*pow(i,j),j++;
    return he;
}
int main(){
    int x,y,z;
    cin>>x>>y>>z;
    for(int i=2;i<=16;i++){
        if(toten(x,i)*toten(y,i)==toten(z,i)){
            cout<<i;
            return 0;
        }
    }
    cout<<0;
}

最好在我的代码上改

2024/6/20 21:05
加载中...