PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000263. Nguyên tố hay không (Prime or Not)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Nguyên tố hay không (Prime or Not)
Prime or Not
Source: SPOJ
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
2
Output
YES
Explanation
is the only even prime; print YES.
Example 2
Input
4
Output
NO
Explanation
is composite, so print NO.
Example 3
Input
3215031751
Output
NO
Explanation
is composite; weak primality tests may be fooled, but the correct output is NO.