Captain America is searching for a new shield to fight with the Thanos . This time he wants a Rectangular Shield. He can hold the rectangular shield of the width, not greater than w and height, not greater than h . Captain wants a special Shield. A special Shield is that whose ratio of width to the height is equal to the ratio of x to the y .
There can be many Special shields and The Captain wants to try every Special Shield with the width a (a ≤ w) and the height b (b ≤ h) and ratio of a to the b equal to the ratio of x to the y .
You have to determine the number of special shields that the captain can try.
Two Shields are said to be different if they have different shield width or different shield height.
The first line contains four integers w , h , x , y .
1 ≤ w , h , x , y ≤ 10^18
( NOTE : You need to take long long int data type to store these values for C/C++ users)
Print one integer — the number of different special shields that meets the aforementioned constraints.
Sample Input 0
17 15 5 3
Sample Output 0
There are 3 possible Shields with width a and height b (5,3), (10,6), (15,9). In all these 3 shields their ratio of width and height is equal to 5 is to 3 (i.e. x is to y).
Sample Input 1
14 16 7 22
Sample Output 1
Actually, this question is from the private contest of a college in our city, I m not able to find out logic I got the partial score, can anyone help?
@karangreat234 @gagangaur @marksman