PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CCBCHBAHAI0000031. Dịch phải một vị trí (Cyclic Right Shift by One)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Dịch phải một vị trí (Cyclic Right Shift by One)
Dịch phải một vị trí (Cyclic Right Shift by One)
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
Given an integer array .
Perform exactly one cyclic right shift. The last element moves to the first position, and every other element moves one position to the right.
Let the resulting array be . For :
and for every such that :
For , the array remains unchanged.
Print .
Input
The first line contains integer . The second line contains integers .
Output
Print the elements after one cyclic right shift on one line.
Subtask
Subtask 1 (100 points): ; .
Example
Input
5
10 20 30 40 50
Output
50 10 20 30 40
Explanation
The value moves to index ; every other element moves exactly one position to the right.