Условие
Показать переводOn each move, choose one rectangle and cut all the way across it, parallel to a side, making two rectangles with positive integer side lengths. Continue until every piece is a square. Squares may have different sizes. Count cuts, not pieces.
Implement rectangle_cutting(height, width).
Input
height: The starting rectangle height.
width: The starting rectangle width.
Output
Return the minimum number of cuts.
Ограничения
1 ≤ height, width ≤ 500. Rotation does not change the answer.
Примеры
Ввод:
width = 3
height = 2
Ожидаемый вывод:
expected = 2
Ввод:
long long width = 3;
long long height = 2;
Ожидаемый вывод:
long long expected = 2;
Ввод:
long width = 3;
long height = 2;
Ожидаемый вывод:
long expected = 2;
Пояснение
Cut off a 2 × 2 square, leaving a 2 × 1 rectangle. One more cut splits the remainder into two unit squares.
Ввод:
width = 4
height = 4
Ожидаемый вывод:
expected = 0
Ввод:
long long width = 4;
long long height = 4;
Ожидаемый вывод:
long long expected = 0;
Ввод:
long width = 4;
long height = 4;
Ожидаемый вывод:
long expected = 0;
Пояснение
The starting rectangle is already a square.
Ссылки
Это задание адаптировано для CodeUtility. Следуйте условию и ограничениям выше.