A12884 | Prime Subtraction
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given two integers $x$ and $y$ (it is guaranteed that $x > y$ ). You may choose any prime integer $p$ and subtract it any number of times from $x$ . Is it possible to make $x$ equal to $y$ ?
Recall that a prime number is a positive integer that has exactly two positive divisors: $1$ and this integer itself. The sequence of prime numbers starts with $2$ , $3$ , $5$ , $7$ , $11$ .
Your program should solve $t$ independent test cases.
Recall that a prime number is a positive integer that has exactly two positive divisors: $1$ and this integer itself. The sequence of prime numbers starts with $2$ , $3$ , $5$ , $7$ , $11$ .
Your program should solve $t$ independent test cases.
输入格式
The first line contains one integer $t$ ( $1 \le t \le 1000$ ) — the number of test cases.
Then $t$ lines follow, each describing a test case. Each line contains two integers $x$ and $y$ ( $1 \le y < x \le 10^{18}$ ).
Then $t$ lines follow, each describing a test case. Each line contains two integers $x$ and $y$ ( $1 \le y < x \le 10^{18}$ ).
输出格式
For each test case, print YES if it is possible to choose a prime number $p$ and subtract it any number of times from $x$ so that $x$ becomes equal to $y$ . 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).
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).
输入输出样例
输入 #1
4 100 98 42 32 1000000000000000000 1 41 40
输出 #1
YES YES YES NO
In the first test of the example you may choose $p = 2$ and subtract it once.
In the second test of the example you may choose $p = 5$ and subtract it twice. Note that you cannot choose $p = 7$ , subtract it, then choose $p = 3$ and subtract it again.
In the third test of the example you may choose $p = 3$ and subtract it $333333333333333333$ times.
In the second test of the example you may choose $p = 5$ and subtract it twice. Note that you cannot choose $p = 7$ , subtract it, then choose $p = 3$ and subtract it again.
In the third test of the example you may choose $p = 3$ and subtract it $333333333333333333$ times.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted