#GL0000373. Các phép biến đổi LCM kỳ lạ (Weird LCM Operations)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Các phép biến đổi LCM kỳ lạ (Weird LCM Operations)
Weird LCM Operations
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given an integer and an array with initially for .
An operation chooses three pairwise distinct indices . Let the old values be , , . Update the three positions simultaneously by
$$a_i\gets\operatorname{lcm}(y,z),\quad a_j\gets\operatorname{lcm}(x,z),\quad a_k\gets\operatorname{lcm}(x,y).$$Construct at most operations so that the final array has the following property: for every integer , there is a subsequence containing at least two different positions whose values have GCD exactly .
No array value may exceed after any operation. A valid answer is guaranteed to exist. There may be several correct operation sequences; a special checker validates the construction.
Input
One input file contains exactly one integer , representing one independent instance of the original problem.
Output
Print an integer on the first line (number of operations). Each of the next lines contains three indices for an operation. Your output need not match the sample output.
Subtasks
- Subtask 1 (20 points): ; at most operations; every resulting value .
- Subtask 2 (30 points): ; at most operations; every resulting value .
- Subtask 3 (50 points): ; at most operations; every resulting value .
Examples
Example 1
Input
3
Output
1
1 2 3
Explanation
Initially . Operation produces . We have , , and , so every required value occurs.
Example 2
Input
7
Output
3
3 5 7
5 6 7
2 3 4
Explanation
The three operations produce . For instance, , , and . Other subsequences of at least two elements yield .
Editorial adaptation: Each PHOJ input file is one independent instance of the original problem.