PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000084. Ước nguyên tố nhỏ nhất (Least prime divisor)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Ước nguyên tố nhỏ nhất (Least prime divisor)
Least prime divisor
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given an odd integer , find its smallest prime divisor. If is prime, then its smallest prime divisor is itself. For example, , so the answer is .
Input
One line contains the odd integer .
Output
Print the smallest prime divisor of .
Subtasks
- Subtask 1 (20 points): ; the integer is odd.
- Subtask 2 (30 points): ; the integer is odd.
- Subtask 3 (50 points): ; the integer is odd.
Examples
Input
49
Output
7
Explanation
The number is odd and greater than . Since and none of the smaller primes divides , its smallest prime divisor is . Print 7.