【CodeForces - 1051B】Relatively Prime Pairs (构造,思维,素数,水题)
題干:
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?105and?(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≤10181≤l<r≤1018,?r?l+1≤3?105r?l+1≤3?105,?(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?llto?rr?inclusive.
If there are multiple solutions, print any of them.
If there exists no solution, print "NO".
Example
Input
1 8Output
YES 2 7 4 1 3 8 6 5解題報告:
? 別忘了輸出YES。
AC代碼:
#include<bits/stdc++.h> #define ll long long using namespace std;int main() {ll l,r;cin>>l>>r;ll cur = l;printf("YES\n");for(ll i = 1; i<=(r-l+1)/2; i++) {printf("%lld %lld\n",cur++,cur++);} return 0; }?
總結
以上是生活随笔為你收集整理的【CodeForces - 1051B】Relatively Prime Pairs (构造,思维,素数,水题)的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 2017中国银行信用卡有效期几年 中国银
 - 下一篇: 2017浦发银行信用卡有效期 有效期对于