Codeforces Round #509 (Div. 2)B title Buying a TV Set

​
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long a, b, x, y, g;
	cin >> a >> b >> x >> y;
	g = __gcd(x, y);
	x /= g;
	y /= g;
	cout << min(a / x, b / y);
}

​

This topic means that there are any high and wide TV screens in the store, under the condition of w<=a, h<=b How many screens w/h fit a specific ratio x/y.

First find the minimum common divisor g, and then use this minimum common divisor to convert x/y into the simplest proportion. This ratio itself represents the minimum screen that meets the requirements, and then see the minimum screen in the range of a and b. The integer multiple of the screen is a few blocks. The smaller one of a/x and b/y is the solution (the screen must conform to both w<=a and h<=b, so take a smaller value)