P10415 [Lanqiao Cup 2023 National A] Cutting
Background
Data provided by: .
Description
Given a $W\times H$ rectangle, where both side lengths are integers. Xiaolan wants to cut it into many small squares with integer side length. Assume there is no loss during cutting. The side length of each square must be at least $2$, leftovers are not allowed, and all squares must have the same size. What is the maximum number of squares that can be cut?
Input Format
Input one line containing two integers $W, H$, separated by a space.
Output Format
Output one line containing one integer, the answer. If there is no feasible plan that meets the requirements, output $0$.
Explanation/Hint
**Sample Explanation 1**
Cut into $5\times 10=50$ squares with side length $2$.
**Constraints**
For $30\%$ of the testdata, $1\le W,H\le 1000$.
For $60\%$ of the testdata, $1\le W,H\le 10^6$.
For all testdata, $1\le W,H\le 10^9$.
Translated by ChatGPT 5