z-rectangle
Mister little Z has a paper in the shape of rectangle with the size of x by y, where 1 <= x,y <= 300.
He wants to cut the paper into squares (with sides with integer values) so that the number of squares is minimized. He is asking you what is the minimal number of squares he can get by cutting the paper.
InputFrom the first line of the standard input read two integers x and y
OutputTo the standard output write one integer representing the minimal number of squares
Input:
Output:
3 3Output:
1Input:
Output:
Explanation: You can see the 4 squares below:
One square has side of 3, and 3 squares have sides of 1
4 3Output:
4Explanation: You can see the 4 squares below:
AAAB
AAAC
AAADOne square has side of 3, and 3 squares have sides of 1
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.