CF BUDDY
← Problems·

1051B · Relatively Prime Pairs

1000 · greedy, math, number theory

Problem: You are given a set of all integers from ll to rr inclusive, l<rl < r, (rl+1)3105(r - l + 1) \le 3 \cdot 10^5 and (rl)(r - l) is always odd.

You want to split these numbers into exactly rl+12\frac{r - l + 1}{2} pairs in such a way that for each pair (i,j)(i, j) the greatest common divisor of ii and jj is equal to 11. Each number should appear in exactly one of the pairs.

Print the resulting pairs or output that no solution exists. If there are multiple solutions, print any of them.

Input Format: The only line contains two integers ll and rr (1l<r10181 \le l < r \le 10^{18}, rl+13105r - l + 1 \le 3 \cdot 10^5, (rl)(r - l) is odd).

Output Format: If any solution exists, print "YES" in the first line. Each of the next rl+12\frac{r - l + 1}{2} lines should contain some pair of integers. GCD of numbers in each pair should be equal to 11. All (rl+1)(r - l + 1) numbers should be pairwise distinct and should have values from ll to rr inclusive.

If there are multiple solutions, print any of them.

If there exists no solution, print "NO".

Sample Cases

Case 1

Input

1 8

Output

YES
2 7
4 1
3 8
6 5

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback