You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
// 给出一个数字,比如(11),将其转为2进制,计算出它的十进制是多少,答案应该是3
|
|
|
|
|
//1234
|
|
|
|
|
int convert(string s, int k) {
|
|
|
|
|
int res = 0;
|
|
|
|
|
for (int i = 0; i < s.size(); i++) {
|
|
|
|
|
int x = s[i] - '0';
|
|
|
|
|
if (x >= k) return -1;
|
|
|
|
|
res += x * pow(k, s.size() - 1 - i); // 105
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
string a, b, c;
|
|
|
|
|
cin >> a >> b >> c;
|
|
|
|
|
|
|
|
|
|
bool flag = false;
|
|
|
|
|
for (int k = 2; k <= 16; k++) {
|
|
|
|
|
int x = convert(a, k);
|
|
|
|
|
int y = convert(b, k);
|
|
|
|
|
int z = convert(c, k);
|
|
|
|
|
if (x * y == z) {
|
|
|
|
|
cout << k << endl;
|
|
|
|
|
flag = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!flag) cout << 0 << endl;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|