output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> using namespace std; long long GCD(long long a, long long b) { if (a % b == 0) return b; else return GCD(b, a % b); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long a, b, x, y; cin >> a >> b >> x >> y; long long uhu = GCD(x, y); x = x / uhu, y = y ...
### Prompt Construct a Cpp code solution to the problem outlined: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a...
#include <bits/stdc++.h> using namespace std; ifstream in; ofstream out; const long long kk = 1000; const long long MOD = 10e9 + 7; long long a, b, x, y; long long GCD(long long n, unsigned long long m) { while (n != 0 && m != 0) { if (n > m) { n %= m; } else { m %= n; } } return (n + m); ...
### Prompt In CPP, your task is to solve the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a c...
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b); int main() { long long int x, y, a, b, c; cin >> x >> y >> a >> b; c = gcd(a, b); c = (x / (a / c) < y / (b / c)) ? x / (a / c) : y / (b / c); cout << c; return 0; } long long int gcd(long long int a, long lon...
### Prompt Your challenge is to write a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to T...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } int main() { long long a, b, x, y, m; cin >> a >> b >> x >> y; m = gcd(x, y); x = x / m; y = y / m; cout << min(a / x, b / y); }
### Prompt Please create a solution in Cpp to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } int main() { long long a, b, x, y, i, z = 999999, c, d, e; cin >> a >> b >> x >> y; z = gcd(x, y); x /= z; y /= z; long long ans = min(a / x, b / y); cout << ans << end...
### Prompt Construct a cpp code solution to the problem outlined: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } int main() { long long a, b, x, y; cin >> a >> b >> x >> y; long long g = gcd(x, y); x /= g, y /= g; long long t = min(a / x, b / y); cout << t << endl; }
### Prompt Your task is to create a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV se...
#include <bits/stdc++.h> long long int Foo(long long int a, long long int b); int main() { long long int a, b, x, y, i, m, n, p; while (scanf("%lld%lld%lld%lld,", &a, &b, &x, &y) == 4) { p = Foo(x, y); x /= p; y /= p; m = a / x; n = b / y; if (m > n) m = n; printf("%I64d", m); } retu...
### Prompt Construct a cpp code solution to the problem outlined: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a...
#include <bits/stdc++.h> using namespace std; inline long long readi() { long long x; return scanf("%lld", &x), x; } long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; } long long a, b, x, y, g; int main() { a = readi(), b = readi(), x = readi(), y = readi(), g = gcd(x, y), x /= g, y /= g; ...
### Prompt Please provide a CPP coded solution to the problem described below: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to T...
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (a == 0) { return b; } return gcd(b % a, a); } int main() { long long int a, b, x, y; cin >> a >> b >> x >> y; long long int g = gcd(min(x, y), max(x, y)); x = x / g; y = y / g; long long int ans...
### Prompt Create a solution in cpp for the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a ce...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return a > 0 ? gcd(b % a, a) : b; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long a, b, c, d, k; cin >> a >> b >> c >> d; k = gcd(c, d); c /= k; d /= k; cout << min(a / c, b / d); return 0; }
### Prompt Your challenge is to write a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to T...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a % b == 0) return b; return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long a, b, x, y, k; cin >> a >> b >> x >> y; k = gcd(x, y); x /= k; y /= k; cout << min(a / x, ...
### Prompt Please create a solution in cpp to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a == 0) { return b; } return gcd(b % a, a); } int main() { long long a, b, x, y; cin >> a >> b >> x >> y; long long g = gcd(x, y); x /= g; y /= g; long long c1 = a / x; long long c2 = b / y; long long a...
### Prompt Please create a solution in CPP to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long gcd(long long p, long long q) { if (q == 0) return p; return gcd(q, p % q); } int main() { long long a, b, p, q; cin >> a >> b >> p >> q; long long d = gcd(p, q); p /= d; q /= d; long long ans1 = a / p, ans2 = b / q; cout << min(ans1, ans2) << en...
### Prompt Please create a solution in CPP to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; int a[1005]; long long gcd(long long a, long long b) { while (b) { long long r = a % b; a = b; b = r; } return a; } int main() { long long a, b, x, y; cin >> a >> b >> x >> y; long long a1 = gcd(x, y); x /= a1; y /= a1; cout << min(a / x, b / y...
### Prompt Please formulate a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); } int main() { long long a, b, x, y; scanf("%lld%lld%lld%lld", &a, &b, &x, &y); long long t = gcd(x, y); x /= t; y /= t; printf("%lld", min(a / x, b / y)); return 0; }
### Prompt Generate a CPP solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a cert...
#include <bits/stdc++.h> int main() { long long a, b, n, m, t2, t1 = 1, x, y; scanf("%lld %lld %lld %lld", &x, &y, &a, &b); n = a; m = b; while (t1 != 0) { t1 = a % b; a = b; b = t1; } n = n / a; m = m / a; t1 = x / n; t2 = y / m; if (t1 > t2) printf("%lld", t2); else printf(...
### Prompt Please formulate a Cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long int min(long long int a, long long int b) { return a < b ? a : b; } long long int gcd(long long int a, long long int b) { if (a == 0) { return b; } else { return gcd(b % a, a); } } int main() { long long int a, b, x, y; scanf("%lld%lld%lld%lld", ...
### Prompt Please provide a CPP coded solution to the problem described below: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to T...
#include <bits/stdc++.h> using namespace std; const unsigned long long mod = 1e9 + 7; void fast() { ios::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); } long long GCD(long long a, long long b) { if (a == 0) return b; return GCD(b % a, a); } int main() { unsigned long long a, b, ...
### Prompt Please create a solution in cpp to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; bool prime[4000005]; void sieve() { for (int i = 0; i < 4000005; i++) prime[i] = true; for (int i = 2; i * i <= 4000005; i++) { if (prime[i] == true) { for (int x = i * i; x <= 4000005; x += i) { prime[x] = false; } } } prime[0] = false; ...
### Prompt Create a solution in cpp for the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a ce...
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int a, b, x, y; cin >> a >> b >> x >> y; long long int cd = gcd(x, y); x /= cd; y /=...
### Prompt Construct a cpp code solution to the problem outlined: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a...
#include <bits/stdc++.h> using namespace std; long long nsd(long long a, long long b) { if (a == 0) return b; if (b == 0) return a; if (b > a) { long long temp = b; b = a; a = temp; } return nsd(a % b, b); } int main() { long long a, b, x, y; cin >> a >> b >> x >> y; long long nsdxy = nsd(x,...
### Prompt Please create a solution in Cpp to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long cmmdc(long long a, long long b) { long long r; while (a > 0) { r = b % a; b = a; a = r; } return b; } int main() { long long a, b, x, y; cin >> a >> b >> x >> y; long long xy = cmmdc(x, y); x /= xy; y /= xy; cout << min(a / x, b / y...
### Prompt Please provide a CPP coded solution to the problem described below: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to T...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } int main() { long long a, b, x, y; cin >> a >> b >> x >> y; long long sb = gcd(x, y); x = x / sb; y = y / sb; cout << min(a / x, b / y) << endl; ...
### Prompt Develop a solution in CPP to the problem described below: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { return b ? gcd(b, a % b) : a; } const int MAX = 1e6 + 7; int main() { long long int a, b, x, y; cin >> a >> b >> x >> y; long long int d = gcd(x, y); x /= d; y /= d; long long int res = min(a / x, b / y); ...
### Prompt Please formulate a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; constexpr int MOD = 1000000007; constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}; constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1}; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (const auto &v : vec) { os << v << ","; ...
### Prompt Generate a CPP solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a cert...
#include <bits/stdc++.h> using namespace std; int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; int ddx[8] = {0, 0, 1, 1, 1, -1, -1, -1}, ddy[8] = {1, -1, 1, 0, -1, 1, 0, -1}; long long MOD = 1000000000; long long POW(long long a, long long b, long long MMM = MOD) { long long ret = 1; for (; b; b >>= 1, a = (a ...
### Prompt Please provide a CPP coded solution to the problem described below: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to T...
#include <bits/stdc++.h> #pragma gcc optimize(o3) using namespace std; long long qpow(long long x, long long y) { return y ? (y & 1 ? x * qpow(x, y - 1) % 1000000007 : qpow(x * x % 1000000007, y / 2)) : 1; } template <typename T> inline void read(T& x) { x = 0; char c; int sign = ...
### Prompt Create a solution in cpp for the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a ce...
#include <bits/stdc++.h> using namespace std; long long int GCD(long long int a, long long int b) { if (a == 0) { return b; } return GCD(b % a, a); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; int q; long long int a, b, x, y; cin >> a >> b >> x >> y; long long int gc = GCD(x...
### Prompt In cpp, your task is to solve the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a c...
#include <bits/stdc++.h> using namespace std; const int oo = 0x7fffffff; const long long OO = 0x7fffffffffffffff; long long gcd(long long a, long long b) { while (b) { a %= b; swap(a, b); } return a; } int main() { ios_base::sync_with_stdio(false); long long a, b, x, y, g; cin >> a >> b >> x >> y; ...
### Prompt Your task is to create a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV se...
#include <bits/stdc++.h> using namespace std; long long int GCD(long long int x, long long int y) { if (x % y == 0) return y; else return GCD(y, x % y); } int main() { long long int a, b, x, y; cin >> a >> b >> x >> y; long long int gcd = GCD(x, y); long long int reduced_x = x / gcd; long long int...
### Prompt Develop a solution in CPP to the problem described below: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> long long a, b, x, y; long long gcd(long long q, long long w) { if (!w) return q; return gcd(w, q % w); } int main() { scanf("%I64d %I64d %I64d %I64d", &a, &b, &x, &y); long long G = gcd(x, y); x /= G; y /= G; long long ans = std::min((long long)(a / x), (long long)(b / y)); pri...
### Prompt Construct a cpp code solution to the problem outlined: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a...
#include <bits/stdc++.h> using namespace ::std; long long int gcd(long long int a, long long int b) { while (b) { a %= b; swap(a, b); } return a; } int main() { long long int a, b, x, y; cin >> a >> b >> x >> y; long long int div = gcd(x, y); x /= div; y /= div; cout << min(a / x, b / y); }
### Prompt Develop a solution in CPP to the problem described below: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; inline long long read() { char c = getchar(); long long num = 0; long long f = 1; while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { num = (num << 3) + (num << 1) + (c ^ 48); c = getchar(); } re...
### Prompt Please formulate a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long a, b, x, y; long long MY_gcd(long long a, long long b) { if (b == 0) return a; return MY_gcd(b, a % b); } int main() { scanf("%lld%lld%lld%lld", &a, &b, &x, &y); long long GCD = MY_gcd(x, y); x /= GCD; y /= GCD; long long t1 = a / x; long long t2 =...
### Prompt Please create a solution in Cpp to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long a; long long b; long long x; long long y; long long calculateGcd(long long a, long long b) { long long gcd = b; long long c = a % b; while (c > 0) { a = b; b = c; c = a % b; if (c <= 0) { gcd = b; break; } } return gcd; } ...
### Prompt Generate a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a cert...
#include <bits/stdc++.h> using namespace std; long long a, b, c, d; long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; } int main() { scanf("%lld %lld %lld %lld", &a, &b, &c, &d); long long ans = gcd(c, d); long long ans1 = c / ans; long long ans2 = d / ans; ans = min(a / ans1, b / ans2);...
### Prompt Construct a CPP code solution to the problem outlined: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a...
#include <bits/stdc++.h> using namespace std; const long long MAX = 1000; const long long MAXN = 1000; const double PI = acos(-1.0); long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; } int main() { long long a, b, x, y; cin >> a >> b >> x >> y; long long minn = x > y ? gcd(x, y) : gcd(y, x);...
### Prompt In CPP, your task is to solve the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a c...
#include <bits/stdc++.h> unsigned long long gcd(unsigned long long a, unsigned long long b) { while (a != 0 && b != 0) { if (a > b) a %= b; else b %= a; } return a + b; } int task_A() { int n; std::cin >> n; std::vector<int> keyboards(n, 0); for (int i = 0; i < n; ++i) { std::cin >...
### Prompt Generate a Cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a cert...
#include <bits/stdc++.h> using namespace std; long long nod(long long a, long long b) { while (a != 0 && b != 0) { if (a > b) { a %= b; } else { b %= a; } } return a + b; } signed main() { long long a, b, x, y; cin >> a >> b >> x >> y; long long l = nod(x, y); x /= l; y /= l; c...
### Prompt Please formulate a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; void solve(); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); { solve(); cout << "\n"; } cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; return 0; } long long ceils(long long ...
### Prompt Construct a cpp code solution to the problem outlined: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a...
#include <bits/stdc++.h> using namespace std; long long a, b, x, y; inline long long read() { long long x = 0, f = 1; char ch; for (ch = getchar(); !isdigit(ch); ch = getchar()) if (ch == '-') f = -1; for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + ch - '0'; return x * f; } long long gcd(lon...
### Prompt In CPP, your task is to solve the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a c...
#include <bits/stdc++.h> using namespace std; long long nod(long long num, long long den); int main() { long long a, b, x, y, numH, numL, del; cin >> a >> b >> x >> y; del = nod(x, y); x = x / del; y = y / del; numL = a / x; numH = b / y; if (numL > numH) cout << numH; else cout << numL; } lon...
### Prompt Please formulate a CPP solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << "," << p.second << ")"; } template <typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { bool first = true; os << "...
### Prompt Construct a Cpp code solution to the problem outlined: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a...
#include <bits/stdc++.h> using namespace std; long long a, b, x, y; long long gcd(long long m, long long n) { long long r; while (n != 0) { r = m % n; m = n; n = r; } return m; } int main() { cin >> a >> b >> x >> y; long long keep = gcd(x, y); x /= keep; y /= keep; cout << min(a / x, b / ...
### Prompt Construct a cpp code solution to the problem outlined: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a...
#include <bits/stdc++.h> using namespace std; const int N = 0; int n, k, x, t; string s; vector<int> v; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } int main() { long long a, b, c, d; cin >> a >> b >> c >> d; long long gd = gcd(c, d); c /= gd; d /= gd; cout << ...
### Prompt Generate a CPP solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a cert...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { long long big, small; big = max(a, b); small = min(a, b); if (small == 0) { return big; } else { return gcd(small, big % small); } } int main() { long long a, b, x, y, factor; cin >> a >> b >> x >> y; facto...
### Prompt Create a solution in cpp for the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a ce...
#include <bits/stdc++.h> int main() { long long a, b, x, y, i, j, l, m, n, o, p; scanf("%I64d%I64d%I64d%I64d", &a, &b, &x, &y); if (x > y) { m = x; l = y; } else { m = y; l = x; } while (l != 0) { n = m % l; m = l; l = n; } x /= m; y /= m; n = a / x; o = b / y; if (n ...
### Prompt Please provide a cpp coded solution to the problem described below: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to T...
#include <bits/stdc++.h> using namespace std; using i64 = int64_t; using u64 = uint64_t; using u8 = uint8_t; using i8 = int8_t; i64 gcd(i64 a, i64 b) { return (0 == b) ? a : gcd(b, a % b); } int main() { ios::sync_with_stdio(false); cin.tie(0); i64 a, b, x, y; cin >> a >> b >> x >> y; i64 g = gcd(x, y); x /...
### Prompt Your task is to create a CPP solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV se...
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; int a[maxn]; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } int main() { int i, j; long long a, b, x, y; cin >> a >> b >> x >> y; long long g = gcd(x, y); x = x / g; y = y / g; long long k1 = a / x; long long...
### Prompt Construct a Cpp code solution to the problem outlined: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a...
#include <bits/stdc++.h> using namespace std; long long func(long long x, long long y) { if (y == 0) { return x; } else { return func(y, x % y); } } int main() { long long a, b, x, y, n, a1, b1; long long ans; cin >> a >> b >> x >> y; n = func(x, y); a1 = x / n; b1 = y / n; ans = min(a / a1,...
### Prompt Develop a solution in Cpp to the problem described below: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; void _print(long long t) { cerr << t; } void _print(int t) { cerr << t; } void _print(string t) { cerr << t; } void _print(char t) { cerr << t; } void _print(long double t) { cerr << t; } void _print(double t) { cerr << t; } void _print(unsigned long long t) { cerr << t; } ...
### Prompt Develop a solution in cpp to the problem described below: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; int v[1003]; int main() { long long a, b, x, y, c, d, r, cx, cy; cin >> a >> b >> x >> y; cx = x; cy = y; while (y > 0) { r = x % y; x = y; y = r; } c = cx / x; d = cy / x; cout << min(a / c, b / d); return 0; }
### Prompt In cpp, your task is to solve the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a c...
#include <bits/stdc++.h> using namespace std; long long Nod(long long a, long long b) { while (a && b) if (a >= b) a %= b; else b %= a; return a | b; } int main() { long long a, b, x, y, dem, demMin = 1, temp, res = 0, curNod; cin >> a >> b >> x >> y; curNod = Nod(x, y); x /= curNod; y...
### Prompt Please formulate a Cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll X, Y, A, B; ll ta, tb, tem; ll gcd(ll a, ll b); int main() { scanf("%I64d%I64d%I64d%I64d", &A, &B, &X, &Y); tem = gcd(X, Y); X /= tem; Y /= tem; ta = B / Y; tb = A / X; printf("%I64d\n", min(ta, tb)); } ll gcd(ll a, ll b) { if (a < b...
### Prompt In cpp, your task is to solve the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a c...
#include <bits/stdc++.h> using namespace std; namespace mine { const int MAX_N = 110000; int mymin(int x, int y) { return x < y ? x : y; } int mymax(int x, int y) { return x > y ? x : y; } long long MOD; long long qpower(long long x, long long e) { long long ans = 1; while (e > 0) { if (e & 1) ans = ans * x % M...
### Prompt Please formulate a Cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (!a) return b; return gcd(b % a, a); } int main() { long long a, b, x, y; cin >> a >> b >> x >> y; long long g = gcd(x, y); x /= g, y /= g; cout << min(a / x, b / y); return 0; }
### Prompt Please create a solution in CPP to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } signed main() { cin.tie(0); cout << setprecision(10); long long a, b, x, y; cin >> a >> b >> x >> y; long long tmp = gcd(x, y); x = x / tmp; y = ...
### Prompt Create a solution in Cpp for the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a ce...
#include <bits/stdc++.h> using namespace std; long long a, b, x, y; long long gcdxy, Max1, Max2; long long gcd(long long x, long long y) { return y > 0 ? gcd(y, x % y) : x; } int main() { scanf("%lld%lld%lld%lld", &a, &b, &x, &y); if (x < y) swap(x, y), swap(a, b); long long z = gcd(x, y); x /= z; y /= z; M...
### Prompt Your task is to create a CPP solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV se...
#include <bits/stdc++.h> using namespace std; long long nzd(long long a, long long b) { long long m = max(a, b); long long n = min(a, b); long long r = 1; while (r != 0) { r = m % n; m = n; n = r; } return m; } int main() { long long a, b, x, y; scanf("%lld %lld %lld %lld", &a, &b, &x, &y); ...
### Prompt Please provide a CPP coded solution to the problem described below: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to T...
#include <bits/stdc++.h> using namespace std; int a[1005]; long long gcd(long long x, long long y) { if (y == 0) return x; return gcd(y, x % y); } int main() { long long n, m, a, b; cin >> n >> m >> a >> b; long long gg = gcd(a, b); a /= gg; b /= gg; long long ans = min(n / a, m / b); cout << ans << e...
### Prompt Develop a solution in CPP to the problem described below: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; unsigned long long gcd(unsigned long long a, unsigned long long b) { while (b) { unsigned long long t = a % b; a = b; b = t; } return a; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); unsigned long long a, b, x, y; cin >> a >> b >> x ...
### Prompt Your challenge is to write a CPP solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to T...
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { long long t; while (y) { t = x % y; x = y; y = t; } return x; } int main() { long long a, b, x, y, ct = 0, m, j = 1, w = 1; scanf("%lld%lld%lld%lld", &a, &b, &x, &y); m = gcd(x, y); x = x / m; y = y / m...
### Prompt Please formulate a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long a, b, x, y, c, d; long long gcd(long long x, long long y) { if (!y) { return x; } else { return gcd(y, x % y); } } int main() { cin >> a >> b >> x >> y; long long g = gcd(x, y); x /= g; y /= g; c = a / x; d = b / y; cout << min(c, d) <<...
### Prompt Your task is to create a Cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV se...
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { if (y == 0) return x; else return gcd(y, x % y); } int main() { long long res, res1, res2; long long x1, y1, a, b; cin >> x1 >> y1 >> a >> b; long long tt = gcd(a, b); a = a / tt; b = b / tt; res1 = x1 / a;...
### Prompt Please formulate a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { return x == 0 ? y : gcd(y % x, x); } int main() { long long a, b, x, y; long long ans = 0; cin >> a >> b >> x >> y; long long t = gcd(x, y); x /= t, y /= t; ans = min(a / x, b / y); cout << ans << endl; return 0; }
### Prompt Your task is to create a CPP solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV se...
#include <bits/stdc++.h> using namespace std; unsigned long long int gcd(unsigned long long int a, unsigned long long int b) { if (a == 0) return b; return gcd(b % a, a); } int main() { unsigned long long int a, b, x, y; cin >> a >> b >> x >> y; cout << min(a / (x / gcd(x, y)), b / (y / gcd(x, y))) << endl; ...
### Prompt Your task is to create a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV se...
#include <bits/stdc++.h> using ll = long long; ll gcd(ll a, ll b) { while (b) { a %= b; std::swap(a, b); } return a; } int32_t main() { ll a, b, x, y; scanf("%lld%lld%lld%lld", &a, &b, &x, &y); ll d = gcd(x, y); x /= d; y /= d; ll maxa = a / x; ll maxb = b / y; printf("%lld\n", std::min(ma...
### Prompt Create a solution in Cpp for the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a ce...
#include <bits/stdc++.h> using namespace std; int gcd(int q, int w) { if (q == 0) return w; else return gcd(w % q, q); } int main() { long long int w, h, x, y, p; cin >> w >> h >> x >> y; p = gcd(x, y); x = x / p; y = y / p; cout << min(w / x, h / y); }
### Prompt Create a solution in cpp for the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a ce...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { long long r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } int main() { long long a, b, x, y, mini; cin >> a >> b >> x >> y; long long div = gcd(x, y); x = x / div; y = y / div; if (...
### Prompt Please create a solution in Cpp to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long a, b, c, d, x, y, xtemp, ytemp, temp, n, i, j; int main() { cin >> a >> b >> x >> y; xtemp = x; ytemp = y; if (xtemp < ytemp) { temp = xtemp; xtemp = ytemp; ytemp = temp; } while ((xtemp % ytemp) != 0) { temp = ytemp; ytemp = (long ...
### Prompt Create a solution in Cpp for the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a ce...
#include <bits/stdc++.h> using namespace std; long long a, b, x, y; long long gcd(long long a, long long b) { long long t; while (b > 0) { t = a % b; a = b; b = t; } return (a); } void input() { cin >> a >> b >> x >> y; long long u = gcd(x, y); x /= u; y /= u; } void output() { cout << min(a...
### Prompt Your challenge is to write a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to T...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } int main() { long long a, b, x, y, l, m; cin >> a >> b >> x >> y; l = x / gcd(x, y); m = y / gcd(x, y); cout << min(a / l, b / m) << endl; return 0; }
### Prompt Your challenge is to write a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to T...
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (a == 0) return b; return gcd(b % a, a); } long long int lcm(long long int x, long long int y) { return ((x * y) / gcd(x, y)); } bool prime(long long int n) { if (n == 1) return false; if (n == 2) return tru...
### Prompt Generate a CPP solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a cert...
#include <bits/stdc++.h> using namespace std; long long a, b, x, y; long long gcd(long long ai, long long bi) { if (bi == 0) return ai; return gcd(bi, ai % bi); } int main() { cin >> a >> b >> x >> y; long long d = gcd(x, y); x = x / d; y = y / d; cout << min(a / x, b / y); }
### Prompt Please formulate a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a == b) { return a; } if (a == 0) { return b; } if (b == 0) { return a; } if (a > b) { return gcd(a % b, b); } else { return gcd(a, b % a); } } int main() { long long a, b, x, y; cin >> ...
### Prompt Generate a Cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a cert...
#include <bits/stdc++.h> using namespace std; int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1}; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } const double PI = acos(-1); const int inf = 0x3f3f3f3f; const int maxn = 1e5 + 11; lon...
### Prompt Your challenge is to write a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to T...
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } long long gcd(long long a, long long b) { if (a == 0) return b; else return (gcd(b % a, a)); } int main() { fast(); long long a, b, c, d; cin >> a >> b >> c >> d; long...
### Prompt Please formulate a Cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } int main() { long long a, b, x, y; cin >> a >> b >> x >> y; long long g = gcd(x, y); x = x / g; y = y / g; long long na = a / x, nb = b / y; long long n = min(na, nb); ...
### Prompt Create a solution in Cpp for the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a ce...
#include <bits/stdc++.h> using namespace std; long long int i, j, k, sum = 0, ans = 0, n; void fastio() { ios_base::sync_with_stdio(false); cin.tie(NULL); } long long int gcd(long long int a, long long int b) { if (b == 0) return a; return gcd(b, a % b); } void solve() { cin >> n >> i >> j >> k; long long i...
### Prompt Your task is to create a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV se...
#include <bits/stdc++.h> using namespace std; long long nzd(long long a, long long b) { if (b == 0) return a; else return nzd(b, a % b); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed << setprecision(10); long long a, b, x, y; cin >> a >> b >> x >> ...
### Prompt Please formulate a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets wit...
#include <bits/stdc++.h> using namespace std; unsigned long long a, b, x, y; unsigned long long gcd(unsigned long long a, unsigned long long b) { if (b == 0) return a; return gcd(b, a % b); } int main() { cin >> a >> b >> x >> y; unsigned long long z = gcd(x, y); x /= z; y /= z; cout << min(a / x, b / y);...
### Prompt Your task is to create a CPP solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV se...
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int u, long long int v) { if (u == 0) return v; else return gcd(v % u, u); } int main() { long long int a, b, x, y; cin >> a >> b >> x >> y; long long int s; if (x > y) s = gcd(x, y); else s = gcd(y, x); x = x / s;...
### Prompt In Cpp, your task is to solve the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a c...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); long long a, b, x, y; cin >> a >> b >> x >> y; long long g = gcd(x, y); x /= g; y /= g; cout << min(...
### Prompt Your task is to create a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV se...
#include <bits/stdc++.h> using namespace std; long long a, b, x, y; long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); } int main() { scanf("%I64d%I64d%I64d%I64d", &a, &b, &x, &y); long long g = gcd(x, y); x /= g, y /= g; printf("%I64d\n", min(a / x, b / y)); return 0; }
### Prompt Your task is to create a cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV se...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) { return a; } gcd(b, a % b); } int main() { long long t = 1; while (t--) { long long a, b, x, y; cin >> a >> b >> x >> y; long long f = gcd(x, y); x = x / f; y = y / f; x = (a / x); ...
### Prompt Your task is to create a CPP solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV se...
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { if (b > a) swap(a, b); while (b != 0) { T r = a % b; a = b; b = r; } return a; } int main() { long long a, b, x, y; cin >> a >> b >> x >> y; long long g = gcd(x, y); x /= g; y /= g; long long n = min(a ...
### Prompt Your task is to create a Cpp solution to the following problem: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV se...
#include <bits/stdc++.h> using namespace std; int a, b, c, res; int main() { cin >> a >> b >> c; vector<int> v = {a, b, c}; sort(v.begin(), v.end()); while (v[0] + v[1] <= v[2]) v[0]++, res++; cout << res << endl; return 0; }
### Prompt Your task is to create a CPP solution to the following problem: Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes she ne...
#include <bits/stdc++.h> using namespace std; int main() { int arr[3]; cin >> arr[0] >> arr[1] >> arr[2]; sort(arr, arr + 3); cout << max(0, arr[2] - (arr[0] + arr[1] - 1)) << "\n"; }
### Prompt Develop a solution in Cpp to the problem described below: Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes she needs to...
#include <bits/stdc++.h> using namespace std; int main() { int p[3]; int x; for (int i = 0; i < 3; i++) { cin >> p[i]; } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 3; j++) { if (p[i] < p[j]) { x = p[i]; p[i] = p[j]; p[j] = x; } } } if (p[0] + p[1]...
### Prompt Your challenge is to write a Cpp solution to the following problem: Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes sh...
#include <bits/stdc++.h> using namespace std; int main() { int a[3]; int i; for (i = 0; i < 3; i++) { cin >> a[i]; } sort(a, a + 3); if (a[0] + a[1] > a[2]) { cout << "0" << endl; } else { int res = a[2] - (a[0] + a[1]) + 1; cout << res << endl; } return 0; }
### Prompt Create a solution in Cpp for the following problem: Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes she needs to spend...
#include <bits/stdc++.h> using namespace std; bool check(int a, int b, int c); int main() { int i, j, a, b, c, minn; scanf("%d %d %d", &a, &b, &c); i = 0; while (!check(a, b, c)) { i++; minn = min(a, b); minn = min(minn, c); if (minn == a) { check(a++, b, c); continue; } if (...
### Prompt In CPP, your task is to solve the following problem: Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes she needs to spen...
#include <bits/stdc++.h> using namespace std; int main() { int a[3]; cin >> a[0] >> a[1] >> a[2]; sort(a, a + 3); int ans = 0; while (a[0] + a[1] <= a[2]) { ans++; a[0]++; } cout << ans << "\n"; return 0; }
### Prompt Your task is to create a CPP solution to the following problem: Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes she ne...
#include <bits/stdc++.h> using namespace std; int a[3]; int main() { cin >> a[0] >> a[1] >> a[2]; sort(a, a + 3); cout << max(0, a[2] - a[1] - a[0] + 1); return 0; }
### Prompt Your challenge is to write a Cpp solution to the following problem: Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes sh...
#include <bits/stdc++.h> using namespace std; int main() { short a, b, c; cin >> a >> b >> c; short u = 0; if (a + b <= c) u += c - a - b + 1; if (a + c <= b) u += b - a - c + 1; if (b + c <= a) u += a - b - c + 1; cout << u; return 0; }
### Prompt Your task is to create a Cpp solution to the following problem: Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes she ne...
#include <bits/stdc++.h> using namespace std; int main() { long long int arr[3]; for (long long int i = 0; i < 3; i++) { cin >> arr[i]; } sort(arr, arr + 3); if ((arr[2] - arr[1] - arr[0] + 1) <= 0) cout << "0"; else cout << (arr[2] - arr[1] - arr[0] + 1); }
### Prompt Create a solution in cpp for the following problem: Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes she needs to spend...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, maxx; cin >> a >> b >> c; maxx = max(c, max(a, b)); if (maxx == b) { b = c; c = maxx; } if (maxx == a) { a = c; c = maxx; } cout << max(0, c - (a + b - 1)) << endl; }
### Prompt Please create a solution in CPP to the following problem: Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes she needs to...
#include <bits/stdc++.h> using namespace std; int a[4], x, y, z; int main() { cin >> a[1] >> a[2] >> a[3]; sort(a + 1, a + 4); x = a[1], y = a[2], z = a[3]; if (x + y > z) cout << 0; else cout << z - x - y + 1; return 0; }
### Prompt Create a solution in CPP for the following problem: Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes she needs to spend...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int res = 0; if (a + b <= c) res += c - (a + b) + 1; if (a + c <= b) res += b - (a + c) + 1; if (b + c <= a) res += a - (b + c) + 1; cout << res; return 0; }
### Prompt Your task is to create a cpp solution to the following problem: Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes she ne...
#include <bits/stdc++.h> using namespace std; int a[4]; int main() { scanf("%d %d %d", a, a + 1, a + 2); sort(a, a + 3); if (a[0] + a[1] > a[2]) { puts("0"); } else printf("%d\n", a[2] - (a[0] + a[1]) + 1); }
### Prompt Please formulate a cpp solution to the following problem: Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes she needs to...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int a, b, c; cin >> a >> b >> c; int a1 = min(a, min(c, b)); int c1 = max(a, max(c, b)); int b1 = a + b + c - a1 - c1; cout << max(0, c1 - b1 - a1 + 1); }
### Prompt Please formulate a Cpp solution to the following problem: Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes she needs to...