Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- signed main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int x, m, L, v;
- string res;
- cin >> x >> m >> L >> v;
- while (v > 0) {
- int k = v % x;
- if (k <= 9) {
- res.push_back('0' + k);
- v /= x;
- }
- else v += m;
- }
- if (res.size() <= L) cout << res + string(L - res.size(), '0');
- else cout << "NO SOLUTION";
- }
Advertisement
Add Comment
Please, Sign In to add comment