#C4340. Largest Square Tiling

    ID: 47868 Type: Default 1000ms 256MiB

Largest Square Tiling

Largest Square Tiling

In this problem, you are given the dimensions of a rectangle, with side lengths (a) and (b). Your task is to determine the side length of the largest square tile that can be used to completely cover the rectangle without any leftover area. Mathematically, this side length is given by the greatest common divisor (gcd) of (a) and (b).

For example, if (a = 15) and (b = 25), then the largest square has a side length of (5), because (gcd(15, 25) = 5).

inputFormat

The input consists of a single line containing two space-separated integers (a) and (b), representing the dimensions of the rectangle.

outputFormat

Output a single integer which is the side length of the largest square that can exactly tile the rectangle.## sample

15 25
5