-
Notifications
You must be signed in to change notification settings - Fork 0
/
B.cpp
48 lines (44 loc) · 800 Bytes
/
B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <bits/stdc++.h>
using namespace std;
const int MAX = 200007;
const int MOD = 1000000007;
void solve() {
int a, b;
cin >> a >> b;
string s;
s += to_string(a);
s += to_string(b);
char mx = '0';
for (char c : s) {
mx = max(mx, c);
}
int base = (int)(mx - '0') + 1;
// cout << base << '\n';
long long base10 = 0;
long long pow = 1;
while (a) {
base10 += pow * (a % 10);
a /= 10;
pow *= base;
}
pow = 1;
while (b) {
base10 += pow * (b % 10);
b /= 10;
pow *= base;
}
// cout << base10 << '\n';
long long pow2 = 1;
int i = 0;
while (base10) {
if (base10 < pow2) {cout << i << '\n'; return;}
pow2 *= base;
i++;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
// int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve();}
solve();
}