This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#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;