Mistrzostwa Polski Szkół Średnich w Programowaniu Zespołowym 2024
Problem description
There is a rectangle of size N × M. You have to partition it into the smallest number of squares of integer lengths. The squares should not overlap each other and they have to completely cover the area of the rectangle. How many squares are necessary?
Write a program which: reads the dimensions of the rectangle, computes the smallest number of squares required to achive the goal and prints the result to the standard output.
Input
The first (and the only one) line of the standard input contains two positive integers N and M, separated by a single blank. These are the height and the width of the rectangle.
Output
The first (and the only one) line of the standard output should contain one integer – the number of squares in the optimal partitioning of the rectangle.
Limits
1 ≤ N, M ≤ 60.
Example
Input | Output | Explanation |
|
|
The example is depicted above. |