Every time you ask for an interval [l, r], you have l, l + 1, l + 2, ..., r that r-l + 1 number, the number you now ask if there is a permutation P . 1 , P 2 ... P n- such that P I and P I +. 1 relatively prime. In particular to ensure that P . 1 and P n- also prime.
Topic Address: http:? //192.168.173.163/JudgeOnline/problem.php cid = 1244 & pid = 7
Topic analysis:
My code:
#include <cstdio> using namespace std; int main() { int T,l,r; scanf("%d",&T); while (T--) { scanf("%d%d",&l,&r); if(l%2==0&&r%2==0) puts("NO"); else if(l%3==0&&r%3==0&&r-l+1==4) puts("NO") ; else puts("YES"); } return 0; }