PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000008. Số nguyên tố hay hợp số (Prime or not Prime!)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Số nguyên tố hay hợp số (Prime or not Prime!)
Prime or not Prime!
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
You are given an integer . A prime is a positive integer with exactly two positive divisors, and itself. Every other integer at least is composite. Determine which type belongs to.
Input
One line containing integer .
Output
Print YES if is prime, and NO otherwise. Use uppercase letters.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
127
Output
YES
Explanation
is not divisible by any of , which are all primes not exceeding . Hence it is prime and the output is YES.
Input
513
Output
NO
Explanation
The digit sum of is , so is divisible by and is composite. Print NO.