Georgiy031

Untitled

Nov 22nd, 2020
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. signed main() {
  2.  
  3.     ios_base::sync_with_stdio(false);
  4.     cin.tie(nullptr);
  5.     cout.tie(nullptr);
  6.  
  7.     int x, m, L, v;
  8.     string res;
  9.     cin >> x >> m >> L >> v;
  10.     while (v > 0) {
  11.         int k = v % x;
  12.         if (k <= 9) {
  13.             res.push_back('0' + k);
  14.             v /= x;
  15.         }
  16.         else v += m;
  17.     }
  18.     if (res.size() <= L) cout << res + string(L - res.size(), '0');
  19.     else cout << "NO SOLUTION";
  20. }
Advertisement
Add Comment
Please, Sign In to add comment