Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- long long nr[20], folosit[20];
- int main() {
- long long b, n, k, i;
- cin >> n >> k;
- k--;
- for (b = 1; b <= n; b++) {
- nr[b - 1] = k % b;
- k /= b;
- }
- for (b = n - 1; b >= 0; b--) {
- i = -1;
- while (nr[b]-- >= 0)
- do
- i++;
- while (folosit[i]);
- folosit[i] = 1;
- cout << i + 1 << ' ';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment