#C326. Maximizing Smaller Square Plots

    ID: 46667 Type: Default 1000ms 256MiB

Maximizing Smaller Square Plots

Maximizing Smaller Square Plots

You are given a rectangular land plot with dimensions length and width. Your task is to divide this plot into smaller square plots such that each square is as large as possible. Note that the side length of each square plot should be the greatest common divisor (gcd) of the length and width. Once the side length is determined, the number of smaller square plots is calculated by:

\( \text{number of plots} = \left( \frac{\text{length}}{\text{gcd(length, width)}} \right) \times \left( \frac{\text{width}}{\text{gcd(length, width)}} \right) \)

Return the number of square plots and the side length of each plot.

inputFormat

The input is provided via stdin as a single line containing two integers:

  • length: the length of the land plot.
  • width: the width of the land plot.

outputFormat

The output should be printed to stdout as a single line containing two space-separated integers:

  • The maximum number of square plots.
  • The side length of each square plot.
## sample
4 6
6 2