#GD0000151. Ghép cặp để ước chung lớn nhất lớn hơn một (GCD Compression)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Ghép cặp để ước chung lớn nhất lớn hơn một (GCD Compression)
GCD Compression
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You have an array of positive integers. Discard exactly two elements, then partition the remaining elements into unordered pairs. Let consist of the sum of the two values in each pair.
Find a pairing such that . It is guaranteed that a valid pairing exists. Output only the original indices of the pairs; the two discarded indices are omitted.
Input
The first line contains . The second line contains integers .
Output
Output exactly lines. Each line contains two distinct -based indices from to . Each index may appear at most once, and the GCD of the corresponding pair sums must exceed one.
Subtasks
- Subtask 1 (20 points): ; for .
- Subtask 2 (30 points): ; for .
- Subtask 3 (50 points): ; for .
Examples
Input
3
1 2 3 4 5 6
Output
2 4
1 3
Explanation
Pairing indices and gives sums and , whose GCD is . Indices and are discarded.