95分求调
https://www.luogu.com.cn/problem/B2141 https://www.luogu.com.cn/record/165654276
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
/**
* @author suystar_bg
* @date 2024/7/13
*/
long long convertToDecimal(string number, int base) {
long long result = 0;
long long multiplier = 1;
for (int i = number.size() - 1; i >= 0; i--) {
result += (number[i] - '0') * multiplier;
multiplier *= base;
}
return result;
}
int main() {
string p, q, r;
cin >> p >> q >> r;
for (int base = 2; base <= 16; base++) {
long long decimalP = convertToDecimal(p, base);
long long decimalQ = convertToDecimal(q, base);
long long decimalR = convertToDecimal(r, base);
if (decimalP * decimalQ == decimalR) {
cout << base << endl;
return 0;
}
}
cout << 0 << endl;
return 0;
}