Aftermath
Time limit2sMemory limit512 MB
Given the integer arithmetic mean a and integer harmonic mean h of the divisors of an unknown n up to 10^15, recover any valid n.
- Level
Hard8 of 10
- Topics
- Number theory, Math, Brute force, Implementation
- Solved
- No attempts yet
Problem
Once upon a time, you had a nice positive integer .
Since you like division, you quickly found all its positive integer divisors.
Not being a mean guy, you calculated , the arithmetic mean of the divisors of . Surprisingly, this number turned out to be an integer.
Some time passed, and you calculated , the harmonic mean of the divisors of . Even more surprisingly, this number turned out to be an integer, too.
Unfortunately, your memory let you down, and now you remember and but don't remember . However, you remember that did not exceed .
Your muse suggested to bring the good old times back and restore any value of matching your records.
Input
The first line of the input contains a single positive integer .
The second line of the input contains a single positive integer .
It is guaranteed that there exists a positive integer such that the arithmetic mean of the divisors of equals , and the harmonic mean of the divisors of equals .
Output
Output any positive integer not exceeding that does not contradict the given information.
Notes
The arithmetic mean is the sum of a collection of numbers divided by the number of numbers in the collection. For example, the arithmetic mean of 1, 2, 3, 6 is .
The harmonic mean is the reciprocal of the arithmetic mean of the reciprocals of the numbers in the collection. For example, the harmonic mean of 1, 2, 3, 6 is .
Thus, in the first example, satisfies the requirements since its divisors are 1, 2, 3, 6.