Relatively Prime Pairs (CodeForces 1051B)

欢迎访问https://blog.csdn.net/lxt_Lucia~~

宇宙第一小仙女\(^o^)/~~萌量爆表求带飞=≡Σ((( つ^o^)つ~ dalao们点个关注呗~~

 

 

Description

You are given a set of all integers from ll to rr inclusive, l<rl<r, (r−l+1)≤3⋅105(r−l+1)≤3⋅105 and (r−l)(r−l) is always odd.

You want to split these numbers into exactly r−l+12r−l+12 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

The only line contains two integers ll and rr (1 ≤ l < r ≤ 1e18 , r − l + 1 ≤ 3⋅1e5 , r − l + 1 ≤ 3⋅1e5 , (r−l)*(r−l) is odd).

 

Output

If any solution exists, print "YES" in the first line. Each of the next r−l+12r−l+12 lines should contain some pair of integers. GCD of numbers in each pair should be equal to 11. All (r−l+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 Input

Input

1 8

Output

YES
2 7
4 1
3 8
6 5

 

题意:

[ l , r ] 区间内可能还出现的所有相对素数对,求素数对数量最多的时候的相对素数对,如果有多种情况,输出其中一种。

 

思路:

有一个很精秒的想法,相邻的两个数一定是相对素数对,也是数量最多的时候,所以输出直接按照 [ l , r ] 区间内的相邻数就可以了,但是数字不能重复。

 

代码:

#include<cstdio>
int main()
{
    long long l,r;
    scanf("%lld %lld",&l,&r);
    printf("YES\n");
    for(long long i=l; i<=r; i+=2)
        printf("%lld %lld\n",i,i+1);
    return 0;
}

 

 

宇宙第一小仙女\(^o^)/~~萌量爆表求带飞=≡Σ((( つ^o^)つ~

dalao们点个关注呗~~

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值