ural 1157. Young Tiler

1157. Young Tiler

Time limit: 1.0 second
Memory limit: 64 MB
One young boy had many-many identical square tiles. He loved putting all his tiles to form a rectangle more, than anything in the world — he has learned the number of all rectangles he can form using his tiles. On his birthday he was presented a number of new tiles. Naturally, he started forming rectangles from these tiles — the thing he loved most of all! Soon he has learned all rectangles he could form with a new number of tiles.
Here we should notice that boy can easily count the number of rectangles, but he has difficulty counting the number of tiles — there are too much of them for such a young boy. But it will not be difficult for you to determine how many tiles he has now, knowing how many rectangles he could form before, how many rectangles he can form now, and how many tiles he got as a birthday present.
You are given numbers MN and K. You should find the smallest number L, such as you can form Ndifferent rectangles using all L tiles, and form M rectangles using L − K tiles.

Input

One line containing three integers: MNK (1 ≤ MNK ≤ 10000).

Output

If L is less than or equal to 10000, then print that number (if there is a number of such L, you should print the smallest one). If there is no solution or smallest L is greater than 10000, print 0.

Sample

inputoutput
2 3 1
16
Problem Source: Ural Collegiate Programming Contest, April 2001, Perm, English Round 
posted @ 2015-10-22 22:12  yanzx6  阅读(157)  评论(0编辑  收藏  举报