Lyft Level 5 Challenge 2018 - Elimination Round
B
Square Difference
Codeforces
1100
原题
← AC →
翻译中…

Alice has a lovely piece of cloth. It has the shape of a square with a side of length $a$ centimeters. Bob also wants such piece of cloth. He would prefer a square with a side of length $b$ centimeters (where $b \lt a$). Alice wanted to make Bob happy, so she cut the needed square out of the corner of her piece and gave it to Bob. Now she is left with an ugly L shaped cloth (see pictures below).

翻译中…

Alice would like to know whether the area of her cloth expressed in square centimeters is prime. Could you help her to determine it?

翻译中…

Input

翻译中…

The first line contains a number $t$ ($1 \leq t \leq 5$) — the number of test cases.

翻译中…

Each of the next $t$ lines describes the $i$-th test case. It contains two integers $a$ and $b~(1 \leq b \lt a \leq 10^{11})$ — the side length of Alice's square and the side length of the square that Bob wants.

翻译中…

Output

翻译中…

Print $t$ lines, where the $i$-th line is the answer to the $i$-th test case. Print "YES" (without quotes) if the area of the remaining piece of cloth is prime, otherwise print "NO".

翻译中…

You can print each letter in an arbitrary case (upper or lower).

翻译中…

Note

翻译中…

The figure below depicts the first test case. The blue part corresponds to the piece which belongs to Bob, and the red part is the piece that Alice keeps for herself. The area of the red part is $6^2 - 5^2 = 36 - 25 = 11$, which is prime, so the answer is "YES".

翻译中…

image

翻译中…

In the second case, the area is $16^2 - 13^2 = 87$, which is divisible by $3$.

翻译中…

image

翻译中…

In the third case, the area of the remaining piece is $61690850361^2 - 24777622630^2 = 3191830435068605713421$. This number is not prime because $3191830435068605713421 = 36913227731 \cdot 86468472991 $.

翻译中…

In the last case, the area is $34^2 - 33^2 = 67$.

翻译中…

样例

Input #1
4
6 5
16 13
61690850361 24777622630
34 33
Output #1
YES
NO
NO
YES
InputCopy OutputCopy
题目信息
题号
1033B
时间限制
2 s
内存限制
256 MB
标签
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。