Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int a[2000], b[2000], h;
- bool check()
- {
- for (int i = 1000; i > -1; i--)
- if (a[i] && !b[i]) return 1;
- else if (!a[i] && b[i]) return 0;
- else if (a[i] && b[i] && a[i] != b[i]) return b[i] < a[i];
- return 1;
- }
- void umn(int t)
- {
- int c = 0, p;
- for (int i = 0; i < 1000; i++)
- p = b[i] * t + c, b[i] = p % 10, c = p / 10;
- }
- int main()
- {
- ios_base::sync_with_stdio(0);
- string s;
- int r, ans = 1;
- cin >> s >> r;
- for (int i = 0; i < s.size(); i++) a[s.size() - i - 1] = s[i] - '0';
- for (int r1 = r; r1; r1 /= 10) b[h++] = r % 10;
- while (check())
- umn(r), ans++;
- cout << ans - 1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement