atcoder#ARC139C. [ARC139C] One Three Nine
[ARC139C] One Three Nine
Score : points
Problem Statement
You are given positive integers and .
Let us call a sequence of pairs of integers wonderful when it satisfies the following.
- and , if .
Make a wonderful sequence of pairs of integers whose length, , is the maximum possible.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print your answer in the following format:
Here, should be the maximum possible length of a wonderful sequence of pairs of integers, and should be a wonderful sequence of pairs of integers. If multiple solutions exist, printing any of them is accepted.
3 4
10
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
3 4
For , there is no wonderful sequence of pairs of integers whose length is or longer, and the above sequence of pairs of integers is wonderful, so this output is valid.