#C6873. Largest Cube Tiling
Largest Cube Tiling
Largest Cube Tiling
In this problem, you are given the dimensions of a rectangular box: its height and width. Your task is to find the side length of the largest cube (which in this 2D context is equivalent to a square) that can completely fill the box without any remaining space. More precisely, given two positive integers (h) and (w), determine the maximum integer (s) such that the box can be exactly tiled by cubes of side (s). Mathematically, (s = \gcd(h, w)).
inputFormat
The input is read from standard input. The first line contains two space-separated positive integers (h) and (w) ( (1 \leq h, w \leq 10^6)) representing the height and width of the box.
outputFormat
Output to standard output a single integer, the side length of the largest cube that can perfectly tile the box.## sample
6 9
3
</p>