Wymagana długość
int main() {
int rs = 0;
ull x;
int n;
cin >> n;
cin >> x;
if (x == 1 && n > 1) {
cout << -1 << endl;
return;
}
int num = log10(x) + 1;
while (num < n) {
int max_char = 0;
ull l = x;
for (int i = 0; i < num; i++) {
max_char = max(max_char, static_cast<int>(l % 10));
l /= 10;
}
x *= max_char;
rs++;
num = log10(x) + 1;
}
cout << rs << endl;
}
Open Ocelot