PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000018. Số nguyên tố (Primality Test)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Số nguyên tố (Primality Test)

Primality Test

Source: LQDOJ

Version: Phuoc Hung OJ Extended

Problem Statement

A positive integer is called prime if it has exactly two distinct positive divisors: 11 and itself. Therefore, 11 is not prime, and 22 is the smallest prime number.

Given a positive integer nn, determine whether it is prime. The result must be exact even for large values of nn.

Input

The only line contains a positive integer nn.

Output

Print exactly YES if nn is prime; otherwise print NO. Letter case is significant.

Subtasks

  • Subtask 1 (20 points): 1≤n≤1051\le n\le10^5.
  • Subtask 2 (30 points): 1≤n≤1081\le n\le10^8.
  • Subtask 3 (50 points): 1≤n≤10121\le n\le10^{12}.

Examples

Example 1

Input

9

Output

NO

Explanation: For n=9n=9, the factorization 9=3⋅39=3\cdot3 shows that 33 is another divisor besides 11 and 99. Thus, print NO.

Example 2

Input

97

Output

YES

Explanation: For n=97n=97, the primes not exceeding ⌊97⌋=9\lfloor\sqrt{97}\rfloor=9 are 2,3,5,72,3,5,7. None divides 9797, so it is prime and the output is YES.