#GD0000161. Biến dãy thành dãy tốt (Make Array Good)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Biến dãy thành dãy tốt (Make Array Good)
Make Array Good
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
An array of positive integers is good if, for every pair of elements, the larger is divisible by the smaller. An operation chooses index and integer and increases by , keeping the new value at most . Construct at most operations making the array good.
Input
The first line contains . The second line contains positive integers .
Output
Print the number of operations (), followed by lines, each containing the index and increment of an operation in execution order.
Subtasks
- Subtask 1 (20 points): ; ; sau mỗi thao tác .
- Subtask 2 (30 points): ; ; sau mỗi thao tác .
- Subtask 3 (50 points): ; ; sau mỗi thao tác .
Examples
Input
4
2 3 5 5
Output
3
2 1
3 3
4 3
Explanation
Increase the second element by , and the third and fourth elements by each. This produces , where every larger value is divisible by every smaller one. Each increment is legal, using only three operations.