提交时间:2023-08-21 22:40:55

运行 ID: 99082

#include <bits/stdc++.h> using namespace std; int main(){ int n,m,k; cin>>n>>m>>k; int max = 0; int tn = n,tm = m,tk = k; while(tn>0){ if(tn%10>max) max = tn%10; tn = tn/10; } while(tm>0){ if(tm%10>max) max = tm%10; tm = tm/10; } while(tk>0){ if(tk%10>max) max = tk%10; tk = tk/10; } for(int i = max+1;i<=16;i++){ tn = n,tm = m,tk = k; int a = 0,b = 0,c = 0; int d = 0; while(tn>0){ a += pow(i,d)*(tn%10); d++; tn = tn/10; } d = 0; while(tm>0){ b += pow(i,d)*(tm%10); d++; tm = tm/10; } d = 0; while(tk>0){ c += pow(i,d)*(tk%10); d++; tk = tk/10; } if(a*b==c) { cout<<i<<endl; return 0; } } cout<<"0"<<endl; return 0; }