PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000262. Kiểm tra số nguyên tố 64-bit (Primality Test)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Kiểm tra số nguyên tố 64-bit (Primality Test)
Primality Test
Source: Library Checker
Version: Phuoc Hung OJ Extended
Problem Statement
Given a positive integer , determine whether is prime. A prime integer is greater than and has exactly two positive divisors: and itself. In particular, is not prime.
Input
One line containing the integer .
Output
Print exactly one word: Yes if is prime, otherwise No.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
1
Output
No
Explanation
is not prime because a prime must exceed , so print No.
Example 2
Input
2
Output
Yes
Explanation
has exactly two positive divisors, and , so print Yes.
Example 3
Input
341
Output
No
Explanation
is composite even though it is a base- pseudoprime, so print No.
Example 4
Input
998244353
Output
Yes
Explanation
is prime, so the deterministic primality test accepts it and prints Yes.