Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- const int N = 1e5 + 5;
- int a[N], sol[N];
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- cerr.tie(nullptr);
- int n, m;
- ll k;
- cin >> n >> m >> k;
- for (int i = 1; i<=n; i++)
- cin >> a[i];
- for (int i = 1; i<=m; i++)
- sol[i] = 1;
- int last = m;
- while (k > 1) {
- if (k % n == 0) {
- sol[last] = n;
- k /= n;
- }
- else {
- sol[last] = k % n;
- k = k / n + 1;
- }
- last--;
- }
- for (int i = 1; i<=m; i++) {
- cout << a[sol[i]] << " ";
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement