PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000143. Hai hoán vị có tổng nguyên tố (Permutation Prime Sums)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Hai hoán vị có tổng nguyên tố (Permutation Prime Sums)
Permutation Prime Sums
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
Given , construct two permutations of such that is prime for every index. Print IMPOSSIBLE if impossible. Any valid pair is accepted.
Input
One line containing .
Output
Two lines, each listing a permutation, or IMPOSSIBLE.
Subtask
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Example
Input
5
Output
1 2 3 4 5
1 5 4 3 2
Explanation
For , the first permutation is and the second is . The coordinate sums are , all prime.