fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void solve (int a[], int n, int k) {
  5. for (int i=0; i<n; i++) {
  6. cout << a[(i+k)%n] << " ";
  7. }
  8. }
  9.  
  10. int main() {
  11. ios_base::sync_with_stdio(false);
  12. cin.tie(nullptr);
  13.  
  14. int n, k; cin >> n >> k;
  15. int a[n];
  16. for (int i=0; i<n; i++) cin >> a[i];
  17. solve (a, n, k%n);
  18. }
Success #stdin #stdout 0s 5292KB
stdin
5 2
1 2 3 4 5
stdout
3 4 5 1 2