{"id":"e12c3fdc-f5dc-4921-af95-60211be9e429","name":"Relatively Prime Pairs","description":"You are given a set of all integers from l to r inclusive (r - l is odd).You want to split these numbers into exactly (r-l+1)/2 pairs in such a way that for each pair (i,j), the greates common divisor of i and j is equal to 1.\r\nEach pair should appear in exactly one of the pairs.\r\n\r\nPrint the resulting pairs or output that no solution exists.","inputFormat":"The only line contains two integer l and r.","outputFormat":"If any solution exists, print \"YES\" in the first line. Each of next (r-l+1)/2 line contains some pair of integers. GCD of each pair of integers should be equal to 1.\r\nIf there exists no solution print \"NO\".","constraints":"1 <= l, r, <= 10^8\r\nr-l+1 <= 10^5 and r-l is odd","sampleCode":{"cpp":{"code":""},"java":{"code":"\r\nimport java.util.*;\r\nimport java.util.function.Function;\r\nimport java.util.stream.Collectors;\r\nimport java.io.*;\r\nimport java.math.*;\r\n\r\npublic class Main {\r\n\t\tpublic static void main(String[] args) {\r\n\r\n\t}\r\n}\r\n"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"1 8\r\n","sampleOutput":"YES\r\n1 2\r\n3 4\r\n5 6\r\n7 8\r\n\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"086949fa-3c5e-40c6-8a9c-f9be4b400318","name":"Number Theory For Experts","slug":"number-theory-for-experts","type":0},{"id":"d8bd2d16-c0f4-4976-a080-a1eea0465200","name":"Relatively Prime Pairs","slug":"relatively-prime-pairs","type":1}],"next":{"id":"b3bdd6a6-75eb-452b-bb32-135945f99b12","name":"Sum Of Factors","type":1,"slug":"sum-of-factors"},"prev":{"id":"c406e72a-1c68-4993-b98b-2a51ad2de329","name":" I Hate 1111","type":1,"slug":"i-hate-1111"}}}

Relatively Prime Pairs

You are given a set of all integers from l to r inclusive (r - l is odd).You want to split these numbers into exactly (r-l+1)/2 pairs in such a way that for each pair (i,j), the greates common divisor of i and j is equal to 1. Each pair should appear in exactly one of the pairs. Print the resulting pairs or output that no solution exists.

{"id":"e12c3fdc-f5dc-4921-af95-60211be9e429","name":"Relatively Prime Pairs","description":"You are given a set of all integers from l to r inclusive (r - l is odd).You want to split these numbers into exactly (r-l+1)/2 pairs in such a way that for each pair (i,j), the greates common divisor of i and j is equal to 1.\r\nEach pair should appear in exactly one of the pairs.\r\n\r\nPrint the resulting pairs or output that no solution exists.","inputFormat":"The only line contains two integer l and r.","outputFormat":"If any solution exists, print \"YES\" in the first line. Each of next (r-l+1)/2 line contains some pair of integers. GCD of each pair of integers should be equal to 1.\r\nIf there exists no solution print \"NO\".","constraints":"1 <= l, r, <= 10^8\r\nr-l+1 <= 10^5 and r-l is odd","sampleCode":{"cpp":{"code":""},"java":{"code":"\r\nimport java.util.*;\r\nimport java.util.function.Function;\r\nimport java.util.stream.Collectors;\r\nimport java.io.*;\r\nimport java.math.*;\r\n\r\npublic class Main {\r\n\t\tpublic static void main(String[] args) {\r\n\r\n\t}\r\n}\r\n"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"1 8\r\n","sampleOutput":"YES\r\n1 2\r\n3 4\r\n5 6\r\n7 8\r\n\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"086949fa-3c5e-40c6-8a9c-f9be4b400318","name":"Number Theory For Experts","slug":"number-theory-for-experts","type":0},{"id":"d8bd2d16-c0f4-4976-a080-a1eea0465200","name":"Relatively Prime Pairs","slug":"relatively-prime-pairs","type":1}],"next":{"id":"b3bdd6a6-75eb-452b-bb32-135945f99b12","name":"Sum Of Factors","type":1,"slug":"sum-of-factors"},"prev":{"id":"c406e72a-1c68-4993-b98b-2a51ad2de329","name":" I Hate 1111","type":1,"slug":"i-hate-1111"}}}
plane

Editor


Loading...

Relatively Prime Pairs

medium

You are given a set of all integers from l to r inclusive (r - l is odd).You want to split these numbers into exactly (r-l+1)/2 pairs in such a way that for each pair (i,j), the greates common divisor of i and j is equal to 1. Each pair should appear in exactly one of the pairs. Print the resulting pairs or output that no solution exists.

Constraints

1 <= l, r, <= 10^8 r-l+1 <= 10^5 and r-l is odd

Format

Input

The only line contains two integer l and r.

Output

If any solution exists, print "YES" in the first line. Each of next (r-l+1)/2 line contains some pair of integers. GCD of each pair of integers should be equal to 1. If there exists no solution print "NO".

Example

Sample Input

1 8

Sample Output

YES 1 2 3 4 5 6 7 8

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode