PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000109. Hoán vị vui nhộn (Fun Permutation)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Hoán vị vui nhộn (Fun Permutation)
Fun Permutation
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given a permutation of , construct another permutation so that for all . A solution always exists; output any valid permutation.
Input
The first line contains . The second line contains permutation .
Output
Print the elements of a valid permutation .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
3
1 3 2
Output
3 1 2
Explanation
Every sum equals , so every adjacent pair of sums has GCD .