提交时间:2023-08-21 21:07:01

运行 ID: 99071

#include<algorithm> #include<iostream> #include<cmath> using namespace std; int p, q, r, i; int f(int y) { int sum{}, n{}; while (y) sum += y % 10 * pow(i, n), y /= 10, n++; return sum; } int g(int n) { int x{}; do x = max(n % 10, x); while (n /= 10); return x; } int main() { cin >> p >> q >> r; for (i = max(max(g(p), g(q)), g(r)) + 1; i < 17; i++) if (f(p) * f(q) == f(r)) { cout << i; break; } return 0; }