#P15894. [TOPC 2025] Twin Guardians
[TOPC 2025] Twin Guardians
Description
In a distant Mathematical Kingdom, there stands an ancient gate known as the “Twin Gate.” Legend has it that the gate will only open when two “Twin Guardians” stand before it at the same time.
The king has summoned a wise adventurer to help determine whether the two given numbers are “Twin Primes.” If they genuinely are Twin Guardians (i.e., Twin Primes), the gate will shine brightly and open; otherwise, it will remain firmly shut.
Definition of Twin Primes: If two numbers and are both prime, they are called “twin primes.”
Input Format
Each test contains multiple test cases. The first line contains the number of test cases . The description of the test cases follows.
The only line of each test case contains two integers and , representing a task assigned by the king that asks you to check these two numbers.
Output Format
For each test case, if and are twin primes, output Y (indicating “Yes, the Twin Gate opens!”); otherwise, output N.
5
2 3
11 13
12 14
3 5
5 7
N
Y
N
Y
Y
5
17 19
29 31
15 17
19 21
41 43
Y
Y
N
N
Y
京公网安备 11011102002149号