Etched Emerald Orbs
Time limit3sMemory limit1024 MB
Given k, find x < y with 2/k = 1/x + 1/y and the smallest x + y, or report -1 if no such pair exists.
- Level
Medium6 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem
An archaeologist team found a tomb of the ancient tribe and discovered emerald orbs inside the tomb. The ancient tribe etched a number on each emerald orb. The archaeologists spent two decades realizing that each emerald orb has a unique number. The numbers run from to , written in the ancient language.
Eddy, the only mathematician on the archaeologist team, recently figured out the relation between the number and the emerald orb numbered . The weight of the emerald orb numbered is exactly grams. Since every orb has a distinct number, no two orbs have the same weight.
Eddy proposes a hypothesis: the ancient tribe used these orbs to represent weights less than gram. Clearly the orb numbered represents gram. Eddy then tries to represent grams for with two orbs. He finds that the orbs numbered and represent grams. Similarly, the orbs numbered and represent grams.
Write a program that checks whether two orbs can represent grams for a given integer . If several pairs of orbs represent grams, output the pair that minimizes the sum of the numbers on them. If no pair exists, output .
Input
The input contains one positive integer .
Output
If there is no solution, output . Otherwise, output two distinct integers and separated by a space, where and . If there are multiple solutions, output the one that minimizes .
Constraints
.