Logo
(追記) (追記ここまで)

34585번 - Twin Guardians 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB97726874.725%

문제

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 $i$ and $i+2$ are both prime, they are called “twin primes.”

입력

Each test contains multiple test cases. The first line contains the number of test cases $t$. The description of the test cases follows.

The only line of each test case contains two integers $a$ and $b,ドル representing a task assigned by the king that asks you to check these two numbers.

출력

For each test case, if $a$ and $b$ are twin primes, output Y (indicating “Yes, the Twin Gate opens!”); otherwise, output N.

제한

  • 1ドル ≤ t ≤ 10$
  • 1ドル ≤ a < b ≤ 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

노트

출처

ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2025 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /