提交时间:2024-08-19 21:17:54

运行 ID: 167957

#include<iostream> #include<cctype> #include<cmath> #include<algorithm> #include<string> #define int long long using namespace std; int bto10(int b,int n){ string s = to_string(n); int k = s.length(),r = 0; reverse(s.begin(),s.end()); for(int i = 0; i < s.length(); i++){ r += (s[i]-'0')*pow(b, i); } return r; } int maxbit(int n){ string s = to_string(n); signed r = 0; for(int i = 0; i < s.length(); i++){ r = max(r,s[i]-'0'); } return r; } signed main(){ int lb = 2; int a,b,c; int x,y,z; cin>>a>>b>>c; lb = max(max(maxbit(a),maxbit(b)),maxbit(c)); for(int i = lb+1; i <= 16; i++){ if(bto10(i,a)*bto10(i,b) == bto10(i,c)){ cout<<i; return 0; } } cout<<0; return 0; }