#P2640. Maximum Magnetic Destruction
Maximum Magnetic Destruction
Maximum Magnetic Destruction
In a one‐dimensional coordinate system, a magnet exerts its maximum magnetic force if and only if it is placed on a coordinate that is a prime number (the magnitude of the coordinate does not matter, as long as it is prime, the force is identical). Furthermore, when two magnets are placed at a distance k apart, the destructive force between them reaches the peak value of the magnetic force.
Given that the destructive force between two magnets depends on both the magnetic force and the distance between them, the pair of magnets that will yield the maximum destructive force are those placed on the smallest and the largest prime coordinates within the coordinate system.
You are given a one-dimensional coordinate system with positions labeled from 1 to n. Your task is to determine which pair of coordinates (both being prime numbers) yields the maximum destructive force. That is, you need to find the pair (pmin, pmax) such that pmin is the smallest prime number and pmax is the largest prime number in the interval [1, n].
If there are less than two prime numbers in [1, n], output -1.
Note: Any formulas used in this problem are formatted in LaTeX. For instance, the distance between two magnets is denoted as \(k\).
inputFormat
The input consists of a single integer n (where n represents the maximum coordinate of the one-dimensional system).
outputFormat
If there exist at least two prime numbers between 1 and n, output the smallest and largest prime numbers separated by a space. Otherwise, output -1.
sample
1
-1