Score: 450 points
问题陈述
对于非负整数 l 和 r (l<r),让 S(l,r) 表示由整数 l 到 r−1 按顺序排列形成的序列 (l,l+1,…,r−2,r−1)。此外,如果一个序列可以表示为 S(2ij,2i(j+1)),其中 i 和 j 是非负整数,则称该序列为好序列。
给定非负整数 L 和 R (L<R)。将序列 S(L,R) 分成最少数量的好序列,并打印出序列的数量和划分。更正式地说,找到最小的正整数 M,存在一系列非负整数对 (l1,r1),(l2,r2),…,(lM,rM) 满足以下条件,并打印出这样的 (l1,r1),(l2,r2),…,(lM,rM)。
- L=l1<r1=l2<r2=⋯=lM<rM=R
- S(l1,r1),S(l2,r2),…,S(lM,rM) 是好序列。
可以证明,只有一个划分可以最小化 M。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
For non-negative integers l and r (l<r), let S(l,r) denote the sequence (l,l+1,…,r−2,r−1) formed by arranging integers from l through r−1 in order. Furthermore, a sequence is called a good sequence if and only if it can be represented as S(2ij,2i(j+1)) using non-negative integers i and j.
You are given non-negative integers L and R (L<R). Divide the sequence S(L,R) into the fewest number of good sequences, and print that number of sequences and the division. More formally, find the minimum positive integer M for which there is a sequence of pairs of non-negative integers (l1,r1),(l2,r2),…,(lM,rM) that satisfies the following, and print such (l1,r1),(l2,r2),…,(lM,rM).
- L=l1<r1=l2<r2=⋯=lM<rM=R
- S(l1,r1),S(l2,r2),…,S(lM,rM) are good sequences.
It can be shown that there is only one division that minimizes M.
Constraints
- 0≤L<R≤260
- All input values are integers.
The input is given from Standard Input in the following format:
L R
Output
Print the answer in the following format:
M
l1 r1
⋮
lM rM
Note that the pairs (l1,r1),…,(lM,rM) should be printed in ascending order.
3 19
Sample Output 1
5
3 4
4 8
8 16
16 18
18 19
S(3,19)=(3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18) can be divided into the following five good sequences, which is the minimum possible number:
- S(3,4)=S(20⋅3,20⋅4)=(3)
- S(4,8)=S(22⋅1,22⋅2)=(4,5,6,7)
- $S(8,16)=S(2^3\cdot 1,2^3\cdot 2)=(8,9,10,11,12,13,14,15)$
- S(16,18)=S(21⋅8,21⋅9)=(16,17)
- S(18,19)=S(20⋅18,20⋅19)=(18)
0 1024
Sample Output 2
1
0 1024
3940649673945088 11549545024454656
Sample Output 3
8
3940649673945088 3940649673949184
3940649673949184 4503599627370496
4503599627370496 9007199254740992
9007199254740992 11258999068426240
11258999068426240 11540474045136896
11540474045136896 11549270138159104
11549270138159104 11549545016066048
11549545016066048 11549545024454656