洛谷打卡第一天,注意要设数据类型long long
#include<bits/stdc++.h>
using namespace std;
long long power(int,int);
long long change(int ,int);
long long change(int b,int p){
int t=p;
int k=0;
long long res=0;
while(t){
res=res+t%10*power(b,k);
k++;
t=t/10;
}
return res;
}
int main(){
int p,q,r;
cin>>p>>q>>r;
int flag=0;
for(int B=2;B<=16;B++){
if(change(B,p)*change(B,q)==change(B,r))
{
cout<<B;
flag=1;
break;
}
}
if(flag==0) cout<<"0"<<endl;
return 0;
}
long long power(int b,int k){
if(k==0) return 1;
else{
return b*power(b,k-1);
}
}