#SP0000029. Ước nguyên tố lớn nhất (Largest Prime Divisor)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Ước nguyên tố lớn nhất (Largest Prime Divisor)
Largest Prime Divisor
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
An integer may be divisible by one or more distinct prime numbers. Given a nonzero integer , consider all distinct prime divisors of .
If there are at least two distinct prime divisors, output the greatest one. Otherwise, output . For example, has two distinct prime divisors, while has only one. The sign of does not affect its prime divisors.
Input
One line containing a nonzero integer .
Output
Print the largest prime divisor of if at least two distinct prime divisors exist; otherwise print -1.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
6
Output
3
Explanation
Since , its distinct prime divisors are and . The largest is .
Input
100
Output
5
Explanation
We have , giving the distinct prime divisors and ; the answer is .
Input
2
Output
-1
Explanation
The number has only one distinct prime divisor, so the output is -1.