QOJ.ac

QOJ

시간 제한: 1 s 메모리 제한: 1024 MB 총점: 100

#15115. 双子守护者

통계

在遥远的数学王国中,耸立着一座被称为“双子之门”的古老门扉。传说只有当两位“双子守护者”同时站在门前时,大门才会开启。

国王召集了一位聪明的冒险家,来帮助确定给定的两个数字是否为“孪生素数”。如果它们确实是双子守护者(即孪生素数),大门就会绽放出耀眼的光芒并开启;否则,它将保持紧闭。

孪生素数的定义:如果两个数 $i$ 和 $i+2$ 都是素数,则它们被称为“孪生素数”。

输入格式

每个测试文件包含多个测试用例。第一行包含测试用例的数量 $t$。接下来是每个测试用例的描述。

每个测试用例仅包含一行,其中包含两个整数 $a$ 和 $b$,代表国王要求你检查的这两个数字。

输出格式

对于每个测试用例,如果 $a$ 和 $b$ 是孪生素数,则输出 Y(表示“是的,双子之门开启了!”);否则,输出 N

数据范围

  • $1 \le t \le 10$
  • $1 \le a < b \le 10^6$

样例

输入样例 1

5
2 3
11 13
12 14
3 5
5 7

输出样例 1

N
Y
N
Y
Y

输入样例 2

5
17 19
29 31
15 17
19 21
41 43

输出样例 2

Y
Y
N
N
Y

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.