You are given two integers xx and yy (it is guaranteed that x>yx>y). You may choose any prime integer pp and subtract it any number of times from xx. Is it possible to make xx equal to yy?
Recall that a prime number is a positive integer that has exactly two positive divisors: 11 and this integer itself. The sequence of prime numbers starts with 22, 33, 55, 77, 1111.
Your program should solve tt independent test cases.
Input
The first line contains one integer tt (1≤t≤10001≤t≤1000) — the number of test cases.
Then tt lines follow, each describing a test case. Each line contains two integers xx and yy (1≤y<x≤10181≤y<x≤1018).
Output
For each test case, print YES if it is possible to choose a prime number pp and subtract it any number of times from xx so that xx becomes equal to yy. Otherwise, print NO.
You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes, and YES will all be recognized as positive answer).
Example
input
Copy
4 100 98 42 32 1000000000000000000 1 41 40output
Copy
YES YES YES NONote
In the first test of the example you may choose p=2p=2 and subtract it once.
In the second test of the example you may choose p=5p=5 and subtract it twice. Note that you cannot choose p=7p=7, subtract it, then choose p=3p=3 and subtract it again.
In the third test of the example you may choose p=3p=3 and subtract it 333333333333333333333333333333333333 times.
题意:x-y能不能被同一个素数有限次减尽
解题目标: 即: x-y能不能被某个素数整除
题目类型:数学题
解题思路:
1)x-y是一个数;
2)任何一个数可以表示为 num = 1*num1*num2*numi;
有限个小于num的数相乘;
3)只有1 = 1*1,只有自己乘自己,且1不是素数,因此为 0;
4)x-y 若为素数, 则减去素数本身减一次;
x-y若为大于1的非素数,则一定可以化为同一素数的有限次相加;
综上 必有解。
AC代码:
#include <bits/stdc++.h>
#define rep(x, a, b) for(int x=a; x<=b; x++)
#define inf 0x3f3f3f3f
using namespace std;
const int N= 2e5+10;
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
long long x, y;
cin>>x>>y;
if(x - y == 1) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}