CF1033B.Square Difference
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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<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?
输入格式
The first line contains a number t ( 1≤t≤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≤b<a≤1011) — the side length of Alice's square and the side length of the square that Bob wants.
输出格式
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).
输入输出样例
输入#1
4 6 5 16 13 61690850361 24777622630 34 33
输出#1
YES NO NO YES
说明/提示
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 62−52=36−25=11 , which is prime, so the answer is "YES".
In the second case, the area is 162−132=87 , which is divisible by 3 .
In the third case, the area of the remaining piece is 616908503612−247776226302=3191830435068605713421 . This number is not prime because $3191830435068605713421 = 36913227731 \cdot 86468472991 $ .
In the last case, the area is 342−332=67 .