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

#SP0000029. Ước nguyên tố lớn nhất (Largest Prime Divisor)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Ướ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 NN, consider all distinct prime divisors of ∣N∣|N|.

If there are at least two distinct prime divisors, output the greatest one. Otherwise, output −1-1. For example, 100=22⋅52100=2^2\cdot5^2 has two distinct prime divisors, while 8=238=2^3 has only one. The sign of NN does not affect its prime divisors.

Input

One line containing a nonzero integer NN.

Output

Print the largest prime divisor of ∣N∣|N| if at least two distinct prime divisors exist; otherwise print -1.

Subtasks

  • Subtask 1 (20 points): 1≤∣N∣≤1051\le |N|\le 10^5.
  • Subtask 2 (30 points): 1≤∣N∣≤1091\le |N|\le 10^9.
  • Subtask 3 (50 points): 1≤∣N∣≤1014−11\le |N|\le 10^{14}-1.

Examples

Input

6

Output

3

Explanation

Since 6=2⋅36=2\cdot3, its distinct prime divisors are 22 and 33. The largest is 33.

Input

100

Output

5

Explanation

We have 100=22⋅52100=2^2\cdot5^2, giving the distinct prime divisors 22 and 55; the answer is 55.

Input

2

Output

-1

Explanation

The number 22 has only one distinct prime divisor, so the output is -1.