CF1238A.Prime Subtraction

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given two integers xx and yy (it is guaranteed that x>yx \gt 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.

给你两个整数 xx 和 yy(保证 x>yx > y)。你可以任选一个质数 pp,并从 xx 中任意次减去 pp。是否可能使 xx 等于 yy?

注意:质数是指恰好有两个正因数(即 11 和它本身)的正整数。质数序列以 22、33、55、77、1111 开始。

你的程序需要解决 tt 个相互独立的测试用例。

输入格式

The first line contains one integer tt (1≤t≤10001 \le t \le 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 \le y \lt x \le 10^{18}).

第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000)—— 表示测试用例的数量。

接下来有 tt 行,每行描述一个测试用例。每行包含两个整数 xx 和 yy(1≤y<x≤10181 \le y \lt x \le 10^{18})。

输出格式

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).

对于每个测试用例,如果存在某个质数 pp,使得可以通过从 xx 中任意多次减去 pp(每次减去的都是同一个 pp),使 xx 变为 yy,则输出 YES;否则输出 NO。

你可以以任意大小写形式输出每个字母(例如,字符串 yEs、yes、Yes 和 YES 均会被判为肯定回答)。

输入输出样例

  • 输入#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=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.

在示例的第一个测试中,你可以选择 p=2p = 2 并将其减去一次。

在示例的第二个测试中,你可以选择 p=5p = 5 并将其减去两次。注意:你不能先选择 p=7p = 7 并减去一次,再选择 p=3p = 3 并再次减去。

在示例的第三个测试中,你可以选择 p=3p = 3 并将其减去 333333333333333333333333333333333333 次。

输入解题思路,AI测评打分。不知道怎么写?

首页