output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> int main() { int a, b, c, m; scanf("%d %d %d %d", &a, &b, &c, &m); if (2 * c < m || c > m * 2) { c = -1; } else if (c < m && 2 * c >= m) c = m; else if (c >= m && c <= m * 2) c = c; if (2 * b <= 2 * m) { b = -1; } else b = 2 * b; if (2 * a <= 2 * m) { a = -1; } else a = 2 * a; if (a == -1 || b == -1 || c == -1) printf("-1\n"); else printf("%d\n%d\n%d\n", a, b, c); }
### Prompt Please create a solution in cpp to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> int main() { int a, b, c, m; scanf("%d %d %d %d", &a, &b, &c, &m); if (2 * c < m || c > m * 2) { c = -1; } else if (c < m && 2 * c >= m) c = m; else if (c >= m && c <= m * 2) c = c; if (2 * b <= 2 * m) { b = -1; } else b = 2 * b; if (2 * a <= 2 * m) { a = -1; } else a = 2 * a; if (a == -1 || b == -1 || c == -1) printf("-1\n"); else printf("%d\n%d\n%d\n", a, b, c); } ```
#include <bits/stdc++.h> using namespace std; void scanint(int &x) { int c = getchar_unlocked(); x = 0; while (((c < 48 || c > 57))) c = getchar_unlocked(); for (; c > 47 && c < 58; c = getchar_unlocked()) { x = (x << 1) + (x << 3) + c - 48; } } int v1, v2, v3, vm, x1, x2, x3; int main() { cin >> v1 >> v2 >> v3 >> vm; if (2 * vm < v3 || vm > 2 * v3) { cout << "-1\n"; getchar(); getchar(); return 0; } if (2 * max(v3, vm) >= 2 * v2 || 2 * max(v3, vm) >= 2 * v1) { cout << "-1\n"; getchar(); getchar(); return 0; } cout << 2 * v1 << endl << 2 * v2 << endl << max(v3, vm) << endl; getchar(); getchar(); return 0; }
### Prompt Construct a Cpp code solution to the problem outlined: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; void scanint(int &x) { int c = getchar_unlocked(); x = 0; while (((c < 48 || c > 57))) c = getchar_unlocked(); for (; c > 47 && c < 58; c = getchar_unlocked()) { x = (x << 1) + (x << 3) + c - 48; } } int v1, v2, v3, vm, x1, x2, x3; int main() { cin >> v1 >> v2 >> v3 >> vm; if (2 * vm < v3 || vm > 2 * v3) { cout << "-1\n"; getchar(); getchar(); return 0; } if (2 * max(v3, vm) >= 2 * v2 || 2 * max(v3, vm) >= 2 * v1) { cout << "-1\n"; getchar(); getchar(); return 0; } cout << 2 * v1 << endl << 2 * v2 << endl << max(v3, vm) << endl; getchar(); getchar(); return 0; } ```
#include <bits/stdc++.h> const double pi = acos(-1); const int MOD = 1e9 + 7; const int INF = 1e9 + 7; const int MAXN = 1e5 + 5; const double eps = 1e-9; using namespace std; int arr[MAXN]; int main() { for (int i = 0; i < 4; i++) scanf("%d", arr + i); for (int a = 0; a <= 300; a++) { if (arr[2] > a || arr[3] > a) continue; if (2 * arr[2] < a || 2 * arr[3] < a) continue; for (int b = a + 1; b <= 300; b++) { if (arr[1] > b) continue; if (2 * arr[1] < b || 2 * arr[3] >= b) continue; for (int c = b + 1; c <= 300; c++) { if (arr[0] > c) continue; if (2 * arr[0] < c || 2 * arr[3] >= c) continue; printf("%d\n%d\n%d\n", c, b, a); return 0; } } } printf("-1\n"); return 0; }
### Prompt Construct a CPP code solution to the problem outlined: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> const double pi = acos(-1); const int MOD = 1e9 + 7; const int INF = 1e9 + 7; const int MAXN = 1e5 + 5; const double eps = 1e-9; using namespace std; int arr[MAXN]; int main() { for (int i = 0; i < 4; i++) scanf("%d", arr + i); for (int a = 0; a <= 300; a++) { if (arr[2] > a || arr[3] > a) continue; if (2 * arr[2] < a || 2 * arr[3] < a) continue; for (int b = a + 1; b <= 300; b++) { if (arr[1] > b) continue; if (2 * arr[1] < b || 2 * arr[3] >= b) continue; for (int c = b + 1; c <= 300; c++) { if (arr[0] > c) continue; if (2 * arr[0] < c || 2 * arr[3] >= c) continue; printf("%d\n%d\n%d\n", c, b, a); return 0; } } } printf("-1\n"); return 0; } ```
#include <bits/stdc++.h> int V[10], v, flag; int main() { scanf("%d%d%d%d", &V[1], &V[2], &V[3], &v); for (int c1 = V[1]; c1 <= 2 * V[1]; c1++) for (int c2 = V[2]; c2 <= 2 * V[2]; c2++) for (int c3 = V[3]; c3 <= 2 * V[3]; c3++) { if (c1 > c2 && c2 > c3 && c1 > 2 * v && c2 > 2 * v && c3 >= v && 2 * v >= c3) { printf("%d\n%d\n%d", c1, c2, c3); return 0; } } printf("-1"); return 0; }
### Prompt Please provide a CPP coded solution to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> int V[10], v, flag; int main() { scanf("%d%d%d%d", &V[1], &V[2], &V[3], &v); for (int c1 = V[1]; c1 <= 2 * V[1]; c1++) for (int c2 = V[2]; c2 <= 2 * V[2]; c2++) for (int c3 = V[3]; c3 <= 2 * V[3]; c3++) { if (c1 > c2 && c2 > c3 && c1 > 2 * v && c2 > 2 * v && c3 >= v && 2 * v >= c3) { printf("%d\n%d\n%d", c1, c2, c3); return 0; } } printf("-1"); return 0; } ```
#include <bits/stdc++.h> using namespace std; int anss[3]; int main() { int V1, V2, V3, Vm, minn, maxx; bool ans; ans = true; scanf("%d%d%d%d", &V1, &V2, &V3, &Vm); minn = 0; maxx = 99999; minn = max(minn, Vm); maxx = min(maxx, 2 * Vm); minn = max(minn, V3); maxx = min(maxx, 2 * V3); if (minn > maxx) ans = false; else { anss[2] = minn; minn = anss[2] + 1; maxx = 99999; minn = max(minn, Vm); minn = max(minn, 2 * Vm + 1); minn = max(minn, V2); maxx = min(maxx, 2 * V2); if (minn > maxx) ans = false; else { anss[1] = minn; minn = anss[1] + 1; maxx = 99999; minn = max(minn, Vm); minn = max(minn, 2 * Vm + 1); minn = max(minn, V1); maxx = min(maxx, 2 * V1); if (minn > maxx) ans = false; else anss[0] = minn; } } if (ans) for (int i = 0; i < 3; i++) printf("%d\n", anss[i]); else printf("-1\n"); return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int anss[3]; int main() { int V1, V2, V3, Vm, minn, maxx; bool ans; ans = true; scanf("%d%d%d%d", &V1, &V2, &V3, &Vm); minn = 0; maxx = 99999; minn = max(minn, Vm); maxx = min(maxx, 2 * Vm); minn = max(minn, V3); maxx = min(maxx, 2 * V3); if (minn > maxx) ans = false; else { anss[2] = minn; minn = anss[2] + 1; maxx = 99999; minn = max(minn, Vm); minn = max(minn, 2 * Vm + 1); minn = max(minn, V2); maxx = min(maxx, 2 * V2); if (minn > maxx) ans = false; else { anss[1] = minn; minn = anss[1] + 1; maxx = 99999; minn = max(minn, Vm); minn = max(minn, 2 * Vm + 1); minn = max(minn, V1); maxx = min(maxx, 2 * V1); if (minn > maxx) ans = false; else anss[0] = minn; } } if (ans) for (int i = 0; i < 3; i++) printf("%d\n", anss[i]); else printf("-1\n"); return 0; } ```
#include <bits/stdc++.h> using namespace std; int a, b, c, d; int main() { cin.sync_with_stdio(false), cin.tie(0); cin >> a >> b >> c >> d; for (long long i = 1; i <= 200; ++i) { for (long long j = 1; j <= 200; ++j) { for (long long k = 1; k <= 200; ++k) { if (i <= j || j <= k) continue; if (i >= a && i <= 2 * a && j >= b && j <= 2 * b && k >= c && k <= 2 * c) { if (k >= d && 2 * d >= k && 2 * d < i && 2 * d < j) { cout << i << endl; cout << j << endl; cout << k << endl; return 0; } } } } } cout << -1 << endl; }
### Prompt Develop a solution in CPP to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int a, b, c, d; int main() { cin.sync_with_stdio(false), cin.tie(0); cin >> a >> b >> c >> d; for (long long i = 1; i <= 200; ++i) { for (long long j = 1; j <= 200; ++j) { for (long long k = 1; k <= 200; ++k) { if (i <= j || j <= k) continue; if (i >= a && i <= 2 * a && j >= b && j <= 2 * b && k >= c && k <= 2 * c) { if (k >= d && 2 * d >= k && 2 * d < i && 2 * d < j) { cout << i << endl; cout << j << endl; cout << k << endl; return 0; } } } } } cout << -1 << endl; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; int a1, b1, c1; scanf("%d %d %d %d", &a, &b, &c, &d); if (d > 2 * c || c > 2 * d) { printf("-1\n"); return 0; } c1 = max(c, d); b1 = max(c1 + 1, b); if (b1 > 2 * b) { printf("-1\n"); return 0; } if (2 * d > 2 * b) { printf("-1\n"); return 0; } b1 = max(b1, 2 * d + 1); if (b1 > 2 * b) { printf("-1\n"); return 0; } a1 = max(a, b1 + 1); if (a1 > 2 * a) { printf("-1\n"); return 0; } if (2 * d > 2 * a) { printf("-1\n"); return 0; } a1 = max(a1, 2 * d + 1); if (a1 > 2 * a) { printf("-1\n"); return 0; } printf("%d\n%d\n%d\n", a1, b1, c1); return 0; }
### Prompt Your task is to create a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; int a1, b1, c1; scanf("%d %d %d %d", &a, &b, &c, &d); if (d > 2 * c || c > 2 * d) { printf("-1\n"); return 0; } c1 = max(c, d); b1 = max(c1 + 1, b); if (b1 > 2 * b) { printf("-1\n"); return 0; } if (2 * d > 2 * b) { printf("-1\n"); return 0; } b1 = max(b1, 2 * d + 1); if (b1 > 2 * b) { printf("-1\n"); return 0; } a1 = max(a, b1 + 1); if (a1 > 2 * a) { printf("-1\n"); return 0; } if (2 * d > 2 * a) { printf("-1\n"); return 0; } a1 = max(a1, 2 * d + 1); if (a1 > 2 * a) { printf("-1\n"); return 0; } printf("%d\n%d\n%d\n", a1, b1, c1); return 0; } ```
#include <bits/stdc++.h> using namespace std; const long long MAX = 1e9; const long double PI = 3.14159265358979323846; const long long INF = 1e6 - 1; long long prime1(long long n) { bool ans = false; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { ans = true; break; } } if (ans == 0) { return 1; } else { return 0; } } long long Catalan(long long n) { long long i, sum; if (n <= 0) { return 1; } sum = 0; for (i = 0; i < n; i++) { sum += Catalan(i) * Catalan((n - 1) - i); } return sum; } using namespace std; int main() { int a, b, c, n; cin >> a >> b >> c >> n; if (2 * c >= n && n >= c && b > n && a > n) cout << a * 2 << " " << b * 2 << " " << n; else if (2 * n >= c && c >= n) cout << a * 2 << " " << b * 2 << " " << c; else cout << -1; }
### Prompt Construct a Cpp code solution to the problem outlined: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const long long MAX = 1e9; const long double PI = 3.14159265358979323846; const long long INF = 1e6 - 1; long long prime1(long long n) { bool ans = false; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { ans = true; break; } } if (ans == 0) { return 1; } else { return 0; } } long long Catalan(long long n) { long long i, sum; if (n <= 0) { return 1; } sum = 0; for (i = 0; i < n; i++) { sum += Catalan(i) * Catalan((n - 1) - i); } return sum; } using namespace std; int main() { int a, b, c, n; cin >> a >> b >> c >> n; if (2 * c >= n && n >= c && b > n && a > n) cout << a * 2 << " " << b * 2 << " " << n; else if (2 * n >= c && c >= n) cout << a * 2 << " " << b * 2 << " " << c; else cout << -1; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v0, v1, v2, vm, a0, a1, a2; bool err = true; scanf("%d%d%d%d", &v2, &v1, &v0, &vm); for (int i = v0; i <= v0 * 2; i++) { for (int j = v1; j <= v1 * 2; j++) { for (int k = v2; k <= v2 * 2; k++) { if (vm <= i && vm <= j && vm <= k && i < j && j < k && vm * 2 >= i && vm * 2 < j) { a0 = k; a1 = j; a2 = i; err = false; break; } } } } if (err) { printf("-1\n"); } else { printf("%d\n%d\n%d\n", a0, a1, a2); } return 0; }
### Prompt In CPP, your task is to solve the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v0, v1, v2, vm, a0, a1, a2; bool err = true; scanf("%d%d%d%d", &v2, &v1, &v0, &vm); for (int i = v0; i <= v0 * 2; i++) { for (int j = v1; j <= v1 * 2; j++) { for (int k = v2; k <= v2 * 2; k++) { if (vm <= i && vm <= j && vm <= k && i < j && j < k && vm * 2 >= i && vm * 2 < j) { a0 = k; a1 = j; a2 = i; err = false; break; } } } } if (err) { printf("-1\n"); } else { printf("%d\n%d\n%d\n", a0, a1, a2); } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); vector<int> vec(5); for (int i = 0; i < 4; i++) cin >> vec[i]; for (int i = vec[0]; i <= 200; i++) { if (2 * vec[0] < i) continue; for (int j = vec[1]; j <= 200; j++) { if (2 * vec[1] < j) continue; for (int k = vec[2]; k <= 200; k++) { if (i > j && j > k) { if (2 * vec[2] < k || 2 * vec[3] < k) continue; if (vec[3] <= i && vec[3] <= j && vec[3] <= k) { if (vec[3] * 2 < i && vec[3] * 2 < j) return cout << i << endl << j << endl << k, 0; } } } } } cout << -1; return 0; }
### Prompt Create a solution in CPP for the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); vector<int> vec(5); for (int i = 0; i < 4; i++) cin >> vec[i]; for (int i = vec[0]; i <= 200; i++) { if (2 * vec[0] < i) continue; for (int j = vec[1]; j <= 200; j++) { if (2 * vec[1] < j) continue; for (int k = vec[2]; k <= 200; k++) { if (i > j && j > k) { if (2 * vec[2] < k || 2 * vec[3] < k) continue; if (vec[3] <= i && vec[3] <= j && vec[3] <= k) { if (vec[3] * 2 < i && vec[3] * 2 < j) return cout << i << endl << j << endl << k, 0; } } } } } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v; cin >> v1 >> v2 >> v3 >> v; if (v > 2 * v3 || v3 > 2 * v || v >= v2) cout << -1 << "\n"; else { int a = max(v, v3); cout << 2 * v1 << " " << 2 * v2 << " " << a << "\n"; } }
### Prompt Generate a cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v; cin >> v1 >> v2 >> v3 >> v; if (v > 2 * v3 || v3 > 2 * v || v >= v2) cout << -1 << "\n"; else { int a = max(v, v3); cout << 2 * v1 << " " << 2 * v2 << " " << a << "\n"; } } ```
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ; int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; int a1, a2, a3; if (max(v3, vm) <= min(vm * 2, v3 * 2)) a3 = max(v3, vm); else return puts("-1"); int min2 = max(a3 + 1, max(v3, max(v2, vm * 2 + 1))); int max2 = v2 * 2; if (min2 <= max2) a2 = min2; else return puts("-1"); int min1 = max(a2 + 1, max(v1, max(v2, vm * 2 + 1))); int max1 = v1 * 2; if (min1 <= max1) a1 = min1; else return puts("-1"); cout << a1 << " " << a2 << " " << a3 << "\n"; }
### Prompt Please create a solution in CPP to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ; int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; int a1, a2, a3; if (max(v3, vm) <= min(vm * 2, v3 * 2)) a3 = max(v3, vm); else return puts("-1"); int min2 = max(a3 + 1, max(v3, max(v2, vm * 2 + 1))); int max2 = v2 * 2; if (min2 <= max2) a2 = min2; else return puts("-1"); int min1 = max(a2 + 1, max(v1, max(v2, vm * 2 + 1))); int max1 = v1 * 2; if (min1 <= max1) a1 = min1; else return puts("-1"); cout << a1 << " " << a2 << " " << a3 << "\n"; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; int flag; while (cin >> v1 >> v2 >> v3 >> vm) { flag = 0; int i, j, k; for (i = 1; i <= 200; i++) { for (j = 1; j < i; j++) { for (k = 1; k < j; k++) { if (2 * v1 >= i && v1 <= i && v2 <= j && 2 * v2 >= j && v3 <= k && 2 * v3 >= k && 2 * vm >= k && vm <= k && 2 * vm < j) { flag = 1; break; } } if (flag) break; } if (flag) break; } if (flag) { cout << i << endl; cout << j << endl; cout << k << endl; } else { cout << "-1" << endl; } } return 0; }
### Prompt Your challenge is to write a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; int flag; while (cin >> v1 >> v2 >> v3 >> vm) { flag = 0; int i, j, k; for (i = 1; i <= 200; i++) { for (j = 1; j < i; j++) { for (k = 1; k < j; k++) { if (2 * v1 >= i && v1 <= i && v2 <= j && 2 * v2 >= j && v3 <= k && 2 * v3 >= k && 2 * vm >= k && vm <= k && 2 * vm < j) { flag = 1; break; } } if (flag) break; } if (flag) break; } if (flag) { cout << i << endl; cout << j << endl; cout << k << endl; } else { cout << "-1" << endl; } } return 0; } ```
#include <bits/stdc++.h> using namespace std; int a, b, c, d, ans1, ans2, ans3; int main() { cin >> a >> b >> c >> d; ans1 = max(a, 2 * d + 1); ans2 = max(b, 2 * d + 1); ans3 = max(c, d); if (ans2 == ans3) { if (ans1 == ans2) { ans1 += 2; } ans2++; } else if (ans1 == ans2) ans1++; if (ans1 > 2 * a) { cout << -1 << endl; } else if (ans2 > 2 * b) { cout << -1 << endl; } else if (ans3 > 2 * c) { cout << -1 << endl; } else if (ans3 > 2 * d) { cout << -1 << endl; } else cout << ans1 << "\n" << ans2 << "\n" << ans3 << endl; return 0; }
### Prompt Generate a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int a, b, c, d, ans1, ans2, ans3; int main() { cin >> a >> b >> c >> d; ans1 = max(a, 2 * d + 1); ans2 = max(b, 2 * d + 1); ans3 = max(c, d); if (ans2 == ans3) { if (ans1 == ans2) { ans1 += 2; } ans2++; } else if (ans1 == ans2) ans1++; if (ans1 > 2 * a) { cout << -1 << endl; } else if (ans2 > 2 * b) { cout << -1 << endl; } else if (ans3 > 2 * c) { cout << -1 << endl; } else if (ans3 > 2 * d) { cout << -1 << endl; } else cout << ans1 << "\n" << ans2 << "\n" << ans3 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int v1, v2, v3, vm; inline long long readll() { int sign = 1; char c; for (c = getchar(); !isdigit(c); c = getchar()) if (c == '-') sign = -sign; long long res = c - '0'; for (c = getchar(); isdigit(c); c = getchar()) res = res * 10 + c - '0'; return sign * res; } void writell(long long x) { if (x < 0) { putchar('-'); x = -x; } if (x > 9) writell(x / 10); putchar(x % 10 + '0'); } void inp() { cin >> v1 >> v2 >> v3 >> vm; } void out() { if (vm < v2 && vm <= 2 * v3 && v3 <= 2 * vm) { writell(v1 * 2); putchar('\n'); writell(v2 * 2); putchar('\n'); writell(min(v3 * 2, vm * 2)); } else { putchar('-'); putchar('1'); } } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); inp(); out(); return 0; }
### Prompt Please formulate a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int v1, v2, v3, vm; inline long long readll() { int sign = 1; char c; for (c = getchar(); !isdigit(c); c = getchar()) if (c == '-') sign = -sign; long long res = c - '0'; for (c = getchar(); isdigit(c); c = getchar()) res = res * 10 + c - '0'; return sign * res; } void writell(long long x) { if (x < 0) { putchar('-'); x = -x; } if (x > 9) writell(x / 10); putchar(x % 10 + '0'); } void inp() { cin >> v1 >> v2 >> v3 >> vm; } void out() { if (vm < v2 && vm <= 2 * v3 && v3 <= 2 * vm) { writell(v1 * 2); putchar('\n'); writell(v2 * 2); putchar('\n'); writell(min(v3 * 2, vm * 2)); } else { putchar('-'); putchar('1'); } } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); inp(); out(); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int minx = -1, miny = -1, minz = -1, maxx = 1000, maxy = 1000, maxz = 1000; int a, b, c, d; cin >> a >> b >> c >> d; minz = max(minz, c); minz = max(minz, d); maxz = min(maxz, 2 * c); maxz = min(maxz, 2 * d); miny = max(miny, b); miny = max(miny, 2 * d + 1); miny = max(miny, minz + 1); maxy = min(maxy, 2 * b); minx = max(minx, a); minx = max(minx, 2 * d + 1); minx = max(minx, miny + 1); maxx = min(maxx, 2 * a); if (maxx < minx || maxy < miny || maxz < minz) { cout << "-1\n"; return 0; } cout << minx << "\n" << miny << "\n" << minz << "\n"; return 0; }
### Prompt Please create a solution in Cpp to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int minx = -1, miny = -1, minz = -1, maxx = 1000, maxy = 1000, maxz = 1000; int a, b, c, d; cin >> a >> b >> c >> d; minz = max(minz, c); minz = max(minz, d); maxz = min(maxz, 2 * c); maxz = min(maxz, 2 * d); miny = max(miny, b); miny = max(miny, 2 * d + 1); miny = max(miny, minz + 1); maxy = min(maxy, 2 * b); minx = max(minx, a); minx = max(minx, 2 * d + 1); minx = max(minx, miny + 1); maxx = min(maxx, 2 * a); if (maxx < minx || maxy < miny || maxz < minz) { cout << "-1\n"; return 0; } cout << minx << "\n" << miny << "\n" << minz << "\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (c * 2 < d || d >= b) cout << -1 << endl; else if (d * 2 < c) cout << -1 << endl; else { cout << a * 2 << endl; cout << b * 2 << endl; cout << max(c, d) << endl; } return 0; }
### Prompt Construct a cpp code solution to the problem outlined: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (c * 2 < d || d >= b) cout << -1 << endl; else if (d * 2 < c) cout << -1 << endl; else { cout << a * 2 << endl; cout << b * 2 << endl; cout << max(c, d) << endl; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int V1, V2, V3, Vm; bool OK(int x) { if (Vm <= x && 2 * Vm >= x) { return true; } return false; } void solve() { int i, j, k; for (i = V1; i <= 2 * V1; ++i) { int r; if (2 * V2 < i) r = 2 * V2; else r = i - 1; for (j = V2; j <= r; ++j) { int rr; if (2 * V3 < j) rr = 2 * V3; else rr = j - 1; for (k = V3; k <= rr; ++k) { if (!OK(i) && !OK(j) && OK(k)) { cout << i << endl; cout << j << endl; cout << k << endl; return; } } } } cout << -1 << endl; } int main(void) { cin >> V1 >> V2 >> V3 >> Vm; solve(); return 0; }
### Prompt Construct a cpp code solution to the problem outlined: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int V1, V2, V3, Vm; bool OK(int x) { if (Vm <= x && 2 * Vm >= x) { return true; } return false; } void solve() { int i, j, k; for (i = V1; i <= 2 * V1; ++i) { int r; if (2 * V2 < i) r = 2 * V2; else r = i - 1; for (j = V2; j <= r; ++j) { int rr; if (2 * V3 < j) rr = 2 * V3; else rr = j - 1; for (k = V3; k <= rr; ++k) { if (!OK(i) && !OK(j) && OK(k)) { cout << i << endl; cout << j << endl; cout << k << endl; return; } } } } cout << -1 << endl; } int main(void) { cin >> V1 >> V2 >> V3 >> Vm; solve(); return 0; } ```
#include <bits/stdc++.h> using namespace std; void ans(int64_t n) { cout << n; exit(0); } int32_t main() { int64_t a, b, c, d; cin >> a >> b >> c >> d; int64_t zl = max(c, d), zr = 2 * min(c, d); if (zl > zr) ans(-1); int64_t z = zl, yl = max(z + 1, max(2 * d + 1, b)), yr = 2 * b; if (yl > yr) ans(-1); int64_t y = yl; int64_t xl = max(y + 1, a); int64_t xr = 2 * a; int64_t x = xl; if (xl > xr) ans(-1); cout << x << endl << y << endl << z; }
### Prompt Develop a solution in CPP to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; void ans(int64_t n) { cout << n; exit(0); } int32_t main() { int64_t a, b, c, d; cin >> a >> b >> c >> d; int64_t zl = max(c, d), zr = 2 * min(c, d); if (zl > zr) ans(-1); int64_t z = zl, yl = max(z + 1, max(2 * d + 1, b)), yr = 2 * b; if (yl > yr) ans(-1); int64_t y = yl; int64_t xl = max(y + 1, a); int64_t xr = 2 * a; int64_t x = xl; if (xl > xr) ans(-1); cout << x << endl << y << endl << z; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; for (int sz1 = a; sz1 <= 2 * a; sz1++) { for (int sz2 = b; sz2 <= 2 * b; sz2++) { for (int sz3 = c; sz3 <= 2 * c; sz3++) { if (!(sz1 > sz2 and sz2 > sz3)) continue; if (d <= sz1 and d <= sz2 and d <= sz3 and (2 * d) >= sz3 and (2 * d) < sz2 and (2 * d) < sz1) { cout << sz1 << endl << sz2 << endl << sz3; return 0; } } } } cout << -1; return 0; }
### Prompt Construct a Cpp code solution to the problem outlined: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; for (int sz1 = a; sz1 <= 2 * a; sz1++) { for (int sz2 = b; sz2 <= 2 * b; sz2++) { for (int sz3 = c; sz3 <= 2 * c; sz3++) { if (!(sz1 > sz2 and sz2 > sz3)) continue; if (d <= sz1 and d <= sz2 and d <= sz3 and (2 * d) >= sz3 and (2 * d) < sz2 and (2 * d) < sz1) { cout << sz1 << endl << sz2 << endl << sz3; return 0; } } } } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int m, n, o, p, flag = 0; cin >> m >> n >> o >> p; for (int i = 1; i <= 200; i++) { for (int k = 1; k < i; k++) { for (int j = 1; j < i; j++) { if (m <= i && 2 * m >= i && n <= k && 2 * n >= k && o <= j && 2 * o >= j && p <= j && 2 * p >= j && 2 * p < k) { cout << i << endl << k << endl << j << endl; flag = 1; return 0; } } } } if (flag == 0) cout << "-1" << endl; return 0; }
### Prompt In Cpp, your task is to solve the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int m, n, o, p, flag = 0; cin >> m >> n >> o >> p; for (int i = 1; i <= 200; i++) { for (int k = 1; k < i; k++) { for (int j = 1; j < i; j++) { if (m <= i && 2 * m >= i && n <= k && 2 * n >= k && o <= j && 2 * o >= j && p <= j && 2 * p >= j && 2 * p < k) { cout << i << endl << k << endl << j << endl; flag = 1; return 0; } } } } if (flag == 0) cout << "-1" << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm, a, b, c; scanf("%d%d%d%d", &v1, &v2, &v3, &vm); a = 2 * v1, b = 2 * v2; if (vm >= v1 || vm >= v2 || max(vm, v3) > 2 * min(vm, v3)) { printf("-1\n"); } else printf("%d\n%d\n%d\n", a, b, 2 * min(vm, v3)); return 0; }
### Prompt Your task is to create a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm, a, b, c; scanf("%d%d%d%d", &v1, &v2, &v3, &vm); a = 2 * v1, b = 2 * v2; if (vm >= v1 || vm >= v2 || max(vm, v3) > 2 * min(vm, v3)) { printf("-1\n"); } else printf("%d\n%d\n%d\n", a, b, 2 * min(vm, v3)); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int s1, s2, s3, v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; s1 = max(v1, 2 * vm + 2); s2 = max(v2, 2 * vm + 1); s3 = max(v3, vm); if (s1 <= 2 * v1 && s2 <= 2 * v2 && s3 <= 2 * v3 && s1 > 2 * vm && s2 > 2 * vm && s3 <= 2 * vm) cout << s1 << endl << s2 << endl << s3 << endl; else cout << -1 << endl; }
### Prompt Your challenge is to write a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int s1, s2, s3, v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; s1 = max(v1, 2 * vm + 2); s2 = max(v2, 2 * vm + 1); s3 = max(v3, vm); if (s1 <= 2 * v1 && s2 <= 2 * v2 && s3 <= 2 * v3 && s1 > 2 * vm && s2 > 2 * vm && s3 <= 2 * vm) cout << s1 << endl << s2 << endl << s3 << endl; else cout << -1 << endl; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; while (scanf("%d%d%d%d", &a, &b, &c, &d) != EOF) { if (d > 2 * c || d >= b || c > 2 * d) { printf("-1\n"); } else { printf("%d\n%d\n%d\n", 2 * a, 2 * b, max(c, d)); } } return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; while (scanf("%d%d%d%d", &a, &b, &c, &d) != EOF) { if (d > 2 * c || d >= b || c > 2 * d) { printf("-1\n"); } else { printf("%d\n%d\n%d\n", 2 * a, 2 * b, max(c, d)); } } return 0; } ```
#include <bits/stdc++.h> using namespace std; int v[4]; int main() { for (int i = 0; i < 4; ++i) scanf("%d", v + i); int mn = min(v[2], v[3]); int mx = max(v[2], v[3]); int c = mx; int b = max(v[1], 2 * c + 1); int a = max(v[0], 2 * v[1] + 1); if (mx <= 2 * mn && v[1] * 2 >= b && v[0] * 2 >= a) { printf("%d\n%d\n%d\n", a, b, c); } else puts("-1"); return 0; }
### Prompt Your task is to create a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int v[4]; int main() { for (int i = 0; i < 4; ++i) scanf("%d", v + i); int mn = min(v[2], v[3]); int mx = max(v[2], v[3]); int c = mx; int b = max(v[1], 2 * c + 1); int a = max(v[0], 2 * v[1] + 1); if (mx <= 2 * mn && v[1] * 2 >= b && v[0] * 2 >= a) { printf("%d\n%d\n%d\n", a, b, c); } else puts("-1"); return 0; } ```
#include <bits/stdc++.h> using namespace std; long long i, j, k, n, y, r, z, t, tt, x, b[322567], a[334563], s, l, c[335444], d[222222], e[222222], m; pair<long long, long long> p[12345], q, pp; int main() { cin >> n >> m >> k >> x; if (2 * k < x || 2 * x < k || x >= m) { cout << -1; return 0; } cout << 2 * n << endl << max(2 * x, m) + 1 << endl << max(k, x); return 0; }
### Prompt Develop a solution in Cpp to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long i, j, k, n, y, r, z, t, tt, x, b[322567], a[334563], s, l, c[335444], d[222222], e[222222], m; pair<long long, long long> p[12345], q, pp; int main() { cin >> n >> m >> k >> x; if (2 * k < x || 2 * x < k || x >= m) { cout << -1; return 0; } cout << 2 * n << endl << max(2 * x, m) + 1 << endl << max(k, x); return 0; } ```
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long powmod(long long a, long long b) { long long res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } int main() { long long a, b, c, d; cin >> a >> b >> c >> d; a *= 2, b *= 2, c *= 2; if ((d < a) && (d < b) && (d <= c)) { if (d < c / 2) c /= 2; else c = d; if ((2 * d >= c)) { if (2 * d < b) { cout << a << "\n" << b << "\n" << c; } else { cout << -1; } } else { cout << -1; } } else { cout << -1; } return 0; }
### Prompt Your challenge is to write a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long powmod(long long a, long long b) { long long res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } int main() { long long a, b, c, d; cin >> a >> b >> c >> d; a *= 2, b *= 2, c *= 2; if ((d < a) && (d < b) && (d <= c)) { if (d < c / 2) c /= 2; else c = d; if ((2 * d >= c)) { if (2 * d < b) { cout << a << "\n" << b << "\n" << c; } else { cout << -1; } } else { cout << -1; } } else { cout << -1; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int vb, vs, vm, vd; bool ok(int v1, int v2, int v3) { if ((v3 >= max(vm, vd)) && (v3 <= 2 * vm) && (v3 <= 2 * vd) && (v2 >= max(vs, vd)) && (v2 <= 2 * vs) && (v2 > 2 * vd) && (v1 >= max(vb, vd)) && (v1 <= 2 * vb) && (v1 > 2 * vd) && (v1 > v2) && (v2 > v3)) return true; return false; } int main() { cin >> vb >> vs >> vm >> vd; for (int i = 1; i <= 200; ++i) { for (int j = 1; j <= 200; ++j) { for (int k = 1; k <= 200; ++k) { if (ok(i, j, k)) { cout << i << ' ' << j << ' ' << k; return 0; } } } } cout << -1; return 0; }
### Prompt Develop a solution in CPP to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int vb, vs, vm, vd; bool ok(int v1, int v2, int v3) { if ((v3 >= max(vm, vd)) && (v3 <= 2 * vm) && (v3 <= 2 * vd) && (v2 >= max(vs, vd)) && (v2 <= 2 * vs) && (v2 > 2 * vd) && (v1 >= max(vb, vd)) && (v1 <= 2 * vb) && (v1 > 2 * vd) && (v1 > v2) && (v2 > v3)) return true; return false; } int main() { cin >> vb >> vs >> vm >> vd; for (int i = 1; i <= 200; ++i) { for (int j = 1; j <= 200; ++j) { for (int k = 1; k <= 200; ++k) { if (ok(i, j, k)) { cout << i << ' ' << j << ' ' << k; return 0; } } } } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 29; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long a[4], i, ans[4] = {0}; for (int i = 0; i < (4); i++) cin >> a[i]; for (int i = 0; i < (2); i++) ans[i] = a[i] * 2; for (i = a[2]; i <= a[2] * 2; i++) { if (a[3] <= i && a[3] * 2 >= i && 2 * a[3] < ans[1]) { ans[2] = i; for (int i = 0; i < (3); i++) cout << ans[i] << endl; return 0; } } cout << -1; return 0; }
### Prompt Create a solution in Cpp for the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int INF = 1 << 29; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long a[4], i, ans[4] = {0}; for (int i = 0; i < (4); i++) cin >> a[i]; for (int i = 0; i < (2); i++) ans[i] = a[i] * 2; for (i = a[2]; i <= a[2] * 2; i++) { if (a[3] <= i && a[3] * 2 >= i && 2 * a[3] < ans[1]) { ans[2] = i; for (int i = 0; i < (3); i++) cout << ans[i] << endl; return 0; } } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long V1, V2, V3, Vm; cin >> V1 >> V2 >> V3 >> Vm; if (Vm <= V3 && 2 * Vm >= V3 && 2 * Vm < V2 && 2 * Vm < V1) { cout << V1 << '\n'; cout << V2 << '\n'; cout << V3 << '\n'; return 0; } V1 *= 2; V2 *= 2; V3 *= 2; if (Vm <= V3 && 2 * Vm >= V3 && 2 * Vm < V2 && 2 * Vm < V1) { cout << V1 << '\n'; cout << V2 << '\n'; cout << V3 << '\n'; return 0; } V1 /= 2; V2 /= 2; V3 /= 2; V1 += V2; V2 += V3; if (Vm <= V3 && 2 * Vm >= V3 && 2 * Vm < V2 && 2 * Vm < V1) { cout << V1 << '\n'; cout << V2 << '\n'; cout << V3 << '\n'; return 0; } cout << "-1"; return 0; }
### Prompt Your task is to create a cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long V1, V2, V3, Vm; cin >> V1 >> V2 >> V3 >> Vm; if (Vm <= V3 && 2 * Vm >= V3 && 2 * Vm < V2 && 2 * Vm < V1) { cout << V1 << '\n'; cout << V2 << '\n'; cout << V3 << '\n'; return 0; } V1 *= 2; V2 *= 2; V3 *= 2; if (Vm <= V3 && 2 * Vm >= V3 && 2 * Vm < V2 && 2 * Vm < V1) { cout << V1 << '\n'; cout << V2 << '\n'; cout << V3 << '\n'; return 0; } V1 /= 2; V2 /= 2; V3 /= 2; V1 += V2; V2 += V3; if (Vm <= V3 && 2 * Vm >= V3 && 2 * Vm < V2 && 2 * Vm < V1) { cout << V1 << '\n'; cout << V2 << '\n'; cout << V3 << '\n'; return 0; } cout << "-1"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int a, b, c, k, m; int main() { cin >> a >> b >> c >> k; if ((c * 2 >= k && c <= k) || (c >= k && c <= 2 * k)) { m = min(max(k, c), c * 2); if ((2 * b >= m && b <= m)) { cout << -1; return 0; } else { cout << a * 2 << " " << b * 2 << " "; } cout << m; } else { cout << -1; return 0; } }
### Prompt Construct a cpp code solution to the problem outlined: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int a, b, c, k, m; int main() { cin >> a >> b >> c >> k; if ((c * 2 >= k && c <= k) || (c >= k && c <= 2 * k)) { m = min(max(k, c), c * 2); if ((2 * b >= m && b <= m)) { cout << -1; return 0; } else { cout << a * 2 << " " << b * 2 << " "; } cout << m; } else { cout << -1; return 0; } } ```
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int main() { ios_base ::sync_with_stdio(0); cin.tie(0); int l, m, s, v; cin >> l >> m >> s >> v; for (int i = l; i <= 2 * l; ++i) { for (int j = m; j <= min(2 * m, i - 1); ++j) { for (int k = s; k <= min(2 * s, j - 1); ++k) { if (i >= 0 && j >= 0 && k >= 0 && v <= k && 2 * v >= k && !(2 * v >= j) && !(2 * v >= i)) { return cout << i << '\n' << j << '\n' << k, 0; } } } } cout << -1; }
### Prompt Create a solution in cpp for the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int main() { ios_base ::sync_with_stdio(0); cin.tie(0); int l, m, s, v; cin >> l >> m >> s >> v; for (int i = l; i <= 2 * l; ++i) { for (int j = m; j <= min(2 * m, i - 1); ++j) { for (int k = s; k <= min(2 * s, j - 1); ++k) { if (i >= 0 && j >= 0 && k >= 0 && v <= k && 2 * v >= k && !(2 * v >= j) && !(2 * v >= i)) { return cout << i << '\n' << j << '\n' << k, 0; } } } } cout << -1; } ```
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const int INF = 1e9; const long long LINF = 1LL * INF * INF; const int MAXN = 200007; const double EPS = 1e-7; int main() { ios_base::sync_with_stdio(0); int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (int b1 = (0); b1 < (200); ++b1) for (int b2 = (0); b2 < (b1); ++b2) for (int b3 = (0); b3 < (b2); ++b3) { if (v1 <= b1 && 2 * v1 >= b1 && v2 <= b2 && 2 * v2 >= b2 && v3 <= b3 && 2 * v3 >= b3 && vm <= b3 && 2 * vm >= b3 && 2 * vm < b2) { cout << b1 << endl << b2 << endl << b3 << endl; return 0; } } cout << -1; return 0; }
### Prompt In cpp, your task is to solve the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const int INF = 1e9; const long long LINF = 1LL * INF * INF; const int MAXN = 200007; const double EPS = 1e-7; int main() { ios_base::sync_with_stdio(0); int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (int b1 = (0); b1 < (200); ++b1) for (int b2 = (0); b2 < (b1); ++b2) for (int b3 = (0); b3 < (b2); ++b3) { if (v1 <= b1 && 2 * v1 >= b1 && v2 <= b2 && 2 * v2 >= b2 && v3 <= b3 && 2 * v3 >= b3 && vm <= b3 && 2 * vm >= b3 && 2 * vm < b2) { cout << b1 << endl << b2 << endl << b3 << endl; return 0; } } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; while (scanf("%d %d %d %d", &v1, &v2, &v3, &vm) == 4) { if (vm < v2) { if (vm > v3) { if (2 * v3 >= vm) { printf("%d\n%d\n%d\n", 2 * v1, 2 * v2, vm); } else printf("-1\n"); } else { if (2 * vm >= v3) { printf("%d\n%d\n%d\n", 2 * v1, 2 * v2, v3); } else printf("-1\n"); } } else printf("-1\n"); } return 0; }
### Prompt Please create a solution in cpp to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; while (scanf("%d %d %d %d", &v1, &v2, &v3, &vm) == 4) { if (vm < v2) { if (vm > v3) { if (2 * v3 >= vm) { printf("%d\n%d\n%d\n", 2 * v1, 2 * v2, vm); } else printf("-1\n"); } else { if (2 * vm >= v3) { printf("%d\n%d\n%d\n", 2 * v1, 2 * v2, v3); } else printf("-1\n"); } } else printf("-1\n"); } return 0; } ```
#include <bits/stdc++.h> using namespace std; int a, b, c, d; int main() { cin >> a >> b >> c >> d; int tem = 0x3f3f3f3f; if (d >= a || d >= b) { return cout << -1, 0; } for (int i = c; i <= c + c; i++) { if (i <= d + d && i >= d) { tem = i; break; } } if (tem == 0x3f3f3f3f) { return cout << -1, 0; } else { cout << a + a << '\n' << b + b << '\n' << tem << '\n'; } return 0; }
### Prompt Create a solution in CPP for the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int a, b, c, d; int main() { cin >> a >> b >> c >> d; int tem = 0x3f3f3f3f; if (d >= a || d >= b) { return cout << -1, 0; } for (int i = c; i <= c + c; i++) { if (i <= d + d && i >= d) { tem = i; break; } } if (tem == 0x3f3f3f3f) { return cout << -1, 0; } else { cout << a + a << '\n' << b + b << '\n' << tem << '\n'; } return 0; } ```
#include <bits/stdc++.h> using namespace std; inline void OPEN(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } int a[10]; int ans[10]; int main() { bool flag = true; for (int i = 1; i <= 4; i++) scanf("%d", &a[i]); ans[3] = max(a[3], a[4]); if (ans[3] > 2 * a[4]) flag = false; if (ans[3] > 2 * a[3]) flag = false; ans[2] = 2 * a[2], ans[1] = 2 * a[1]; if (ans[2] <= ans[3] * 2) flag = false; if (!flag) printf("-1\n"); else printf("%d %d %d\n", ans[1], ans[2], ans[3]); return 0; }
### Prompt Your task is to create a cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; inline void OPEN(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } int a[10]; int ans[10]; int main() { bool flag = true; for (int i = 1; i <= 4; i++) scanf("%d", &a[i]); ans[3] = max(a[3], a[4]); if (ans[3] > 2 * a[4]) flag = false; if (ans[3] > 2 * a[3]) flag = false; ans[2] = 2 * a[2], ans[1] = 2 * a[1]; if (ans[2] <= ans[3] * 2) flag = false; if (!flag) printf("-1\n"); else printf("%d %d %d\n", ans[1], ans[2], ans[3]); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, x; cin >> a >> b >> c >> d; if (d <= 2 * c && d < b && c <= 2 * d) { cout << a * 2 << "\n" << b * 2 << "\n"; x = (c >= d) ? c : d; cout << x << endl; } else cout << "-1"; }
### Prompt In cpp, your task is to solve the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, x; cin >> a >> b >> c >> d; if (d <= 2 * c && d < b && c <= 2 * d) { cout << a * 2 << "\n" << b * 2 << "\n"; x = (c >= d) ? c : d; cout << x << endl; } else cout << "-1"; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; scanf("%d %d %d %d", &v1, &v2, &v3, &vm); bool ok = false; for (int c1 = max(v1, 2 * vm + 1); c1 <= 2 * v1 && !ok; c1++) { for (int c2 = max(v2, 2 * vm + 1); c2 <= 2 * v2 && c2 < c1 && !ok; c2++) { for (int c3 = max(v3, vm); c3 <= 2 * v3 && c3 <= 2 * vm && c3 < c2 && !ok; c3++) { ok = true; printf("%d\n%d\n%d\n", c1, c2, c3); } } } if (!ok) printf("-1\n"); return 0; }
### Prompt Please formulate a cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; scanf("%d %d %d %d", &v1, &v2, &v3, &vm); bool ok = false; for (int c1 = max(v1, 2 * vm + 1); c1 <= 2 * v1 && !ok; c1++) { for (int c2 = max(v2, 2 * vm + 1); c2 <= 2 * v2 && c2 < c1 && !ok; c2++) { for (int c3 = max(v3, vm); c3 <= 2 * v3 && c3 <= 2 * vm && c3 < c2 && !ok; c3++) { ok = true; printf("%d\n%d\n%d\n", c1, c2, c3); } } } if (!ok) printf("-1\n"); return 0; } ```
#include <bits/stdc++.h> using namespace std; int v1, v2, v3, v4; int main() { cin >> v1 >> v2 >> v3 >> v4; int a[] = {v1 * 2, v2 * 2, v3 * 2}; int ans[3]; if (v4 > a[2] || v4 * 2 < v3) cout << "-1"; else { ans[2] = max(v4, v3); ans[1] = max(2 * v4 + 1, v2); ans[0] = max(2 * v4 + 2, v1); if (ans[1] > a[1] || ans[0] > a[0]) cout << "-1"; else cout << ans[0] << "\n" << ans[1] << "\n" << ans[2]; } }
### Prompt Your challenge is to write a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int v1, v2, v3, v4; int main() { cin >> v1 >> v2 >> v3 >> v4; int a[] = {v1 * 2, v2 * 2, v3 * 2}; int ans[3]; if (v4 > a[2] || v4 * 2 < v3) cout << "-1"; else { ans[2] = max(v4, v3); ans[1] = max(2 * v4 + 1, v2); ans[0] = max(2 * v4 + 2, v1); if (ans[1] > a[1] || ans[0] > a[0]) cout << "-1"; else cout << ans[0] << "\n" << ans[1] << "\n" << ans[2]; } } ```
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } float inf = std::numeric_limits<double>::infinity(); long long int INF = std::numeric_limits<long long int>::max(); int main() { int a, b, c, d; scanf("%d", &a); scanf("%d", &b); scanf("%d", &c); scanf("%d", &d); int x, y, z; z = max(c, d); if (z > 2 * c || z > 2 * d) return 0 * puts("-1"); y = max(b, max(z, 2 * d) + 1); if (y > 2 * b) return 0 * puts("-1"); x = max(a, y + 1); if (x > 2 * a) return 0 * puts("-1"); printf("%d %d %d\n", x, y, z); return 0; }
### Prompt Construct a CPP code solution to the problem outlined: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } float inf = std::numeric_limits<double>::infinity(); long long int INF = std::numeric_limits<long long int>::max(); int main() { int a, b, c, d; scanf("%d", &a); scanf("%d", &b); scanf("%d", &c); scanf("%d", &d); int x, y, z; z = max(c, d); if (z > 2 * c || z > 2 * d) return 0 * puts("-1"); y = max(b, max(z, 2 * d) + 1); if (y > 2 * b) return 0 * puts("-1"); x = max(a, y + 1); if (x > 2 * a) return 0 * puts("-1"); printf("%d %d %d\n", x, y, z); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int m_size = 0, f_size = 0, s_size = 0, masha_size = 0; cin >> f_size >> m_size >> s_size >> masha_size; int f_car = -1, m_car = -1, s_car = -1; for (int i = 2 * f_size; i >= f_size; i--) { if (i > 2 * masha_size) { f_car = i; break; } } for (int i = 2 * m_size; i >= m_size; i--) { if (i > 2 * masha_size && i < f_car) { m_car = i; break; } } for (int i = 2 * s_size; i >= s_size; i--) { if (i >= masha_size && i <= 2 * masha_size && i < m_car) { s_car = i; break; } } if (f_car == -1 || m_car == -1 || s_car == -1) cout << -1; else { cout << f_car << endl << m_car << endl << s_car << endl; } }
### Prompt Your challenge is to write a cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int m_size = 0, f_size = 0, s_size = 0, masha_size = 0; cin >> f_size >> m_size >> s_size >> masha_size; int f_car = -1, m_car = -1, s_car = -1; for (int i = 2 * f_size; i >= f_size; i--) { if (i > 2 * masha_size) { f_car = i; break; } } for (int i = 2 * m_size; i >= m_size; i--) { if (i > 2 * masha_size && i < f_car) { m_car = i; break; } } for (int i = 2 * s_size; i >= s_size; i--) { if (i >= masha_size && i <= 2 * masha_size && i < m_car) { s_car = i; break; } } if (f_car == -1 || m_car == -1 || s_car == -1) cout << -1; else { cout << f_car << endl << m_car << endl << s_car << endl; } } ```
#include <bits/stdc++.h> using namespace std; ifstream in("input.txt"); ofstream out("output.txt"); const int MAXN = 1e5 + 7; const long long MAXL = 1e18; const int N = 1e7; const double eps = 1e-11; int main() { int a, b, c, d; cin >> a >> b >> c >> d; for (int mini = 1; mini <= 200; ++mini) { for (int sr = mini + 1; sr <= 200; ++sr) { for (int maxi = sr + 1; maxi <= 200; ++maxi) { if (a <= maxi && a * 2 >= maxi && b <= sr && b * 2 >= sr && c <= mini && c * 2 >= mini && d <= maxi && d * 2 < maxi && d <= sr && d * 2 < sr && d <= mini && d * 2 >= mini) { cout << maxi << "\n" << sr << "\n" << mini << "\n"; return 0; } } } } cout << -1 << "\n"; return 0; }
### Prompt In Cpp, your task is to solve the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; ifstream in("input.txt"); ofstream out("output.txt"); const int MAXN = 1e5 + 7; const long long MAXL = 1e18; const int N = 1e7; const double eps = 1e-11; int main() { int a, b, c, d; cin >> a >> b >> c >> d; for (int mini = 1; mini <= 200; ++mini) { for (int sr = mini + 1; sr <= 200; ++sr) { for (int maxi = sr + 1; maxi <= 200; ++maxi) { if (a <= maxi && a * 2 >= maxi && b <= sr && b * 2 >= sr && c <= mini && c * 2 >= mini && d <= maxi && d * 2 < maxi && d <= sr && d * 2 < sr && d <= mini && d * 2 >= mini) { cout << maxi << "\n" << sr << "\n" << mini << "\n"; return 0; } } } } cout << -1 << "\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (int i = 1; i <= 200; i++) { for (int j = i + 1; j <= 200; j++) { for (int k = j + 1; k <= 200; k++) { if ((v1 <= k) && (v2 <= j) && (v3 <= i) && (vm <= k) && (vm <= j) && (vm <= i) && (2 * v1 >= k) && (2 * v2 >= j) && (2 * v3 >= i) && (2 * vm >= i) && (2 * vm < j) && (2 * vm < k)) { cout << k << "\n" << j << "\n" << i << "\n"; return 0; } } } } cout << -1 << "\n"; }
### Prompt Construct a CPP code solution to the problem outlined: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (int i = 1; i <= 200; i++) { for (int j = i + 1; j <= 200; j++) { for (int k = j + 1; k <= 200; k++) { if ((v1 <= k) && (v2 <= j) && (v3 <= i) && (vm <= k) && (vm <= j) && (vm <= i) && (2 * v1 >= k) && (2 * v2 >= j) && (2 * v3 >= i) && (2 * vm >= i) && (2 * vm < j) && (2 * vm < k)) { cout << k << "\n" << j << "\n" << i << "\n"; return 0; } } } } cout << -1 << "\n"; } ```
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(false), cin.tie(0); ; int fb, mb, sb, m; cin >> fb >> mb >> sb >> m; bool possible = false; for (int i = 1; i < 201; i++) { for (int j = i + 1; j < 201; j++) { for (int k = j + 1; k < 201; k++) { if ((i >= m && i <= 2 * m) && !(j >= m && j <= 2 * m) && !(k >= m && k <= 2 * m)) { if ((i >= sb && i <= 2 * sb) && (j >= mb && j <= 2 * mb) && (k >= fb && k <= 2 * fb)) { cout << k << "\n" << j << "\n" << i << "\n"; possible = true; goto looped; } } } } } looped: if (!possible) { cout << -1 << '\n'; } return 0; }
### Prompt Your task is to create a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(false), cin.tie(0); ; int fb, mb, sb, m; cin >> fb >> mb >> sb >> m; bool possible = false; for (int i = 1; i < 201; i++) { for (int j = i + 1; j < 201; j++) { for (int k = j + 1; k < 201; k++) { if ((i >= m && i <= 2 * m) && !(j >= m && j <= 2 * m) && !(k >= m && k <= 2 * m)) { if ((i >= sb && i <= 2 * sb) && (j >= mb && j <= 2 * mb) && (k >= fb && k <= 2 * fb)) { cout << k << "\n" << j << "\n" << i << "\n"; possible = true; goto looped; } } } } } looped: if (!possible) { cout << -1 << '\n'; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int dad, mum, son, masha; bool ccheck(int tx, int ty, int tz) { if (dad > tx) return 0; if (2 * dad < tx) return 0; if (mum > ty) return 0; if (2 * mum < ty) return 0; if (son > tz) return 0; if (2 * son < tz) return 0; if (masha > tz) return 0; if (masha * 2 < tz) return 0; if (masha * 2 >= ty) return 0; return 1; } int main() { ios::sync_with_stdio(false); cin >> dad >> mum >> son >> masha; for (int i = 1; i <= 250; i++) { for (int j = 1; j < i; j++) { for (int k = 1; k < j; k++) { if (ccheck(i, j, k)) { cout << i << endl << j << endl << k << endl; exit(0); } } } } cout << -1; return 0; }
### Prompt Develop a solution in CPP to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int dad, mum, son, masha; bool ccheck(int tx, int ty, int tz) { if (dad > tx) return 0; if (2 * dad < tx) return 0; if (mum > ty) return 0; if (2 * mum < ty) return 0; if (son > tz) return 0; if (2 * son < tz) return 0; if (masha > tz) return 0; if (masha * 2 < tz) return 0; if (masha * 2 >= ty) return 0; return 1; } int main() { ios::sync_with_stdio(false); cin >> dad >> mum >> son >> masha; for (int i = 1; i <= 250; i++) { for (int j = 1; j < i; j++) { for (int k = 1; k < j; k++) { if (ccheck(i, j, k)) { cout << i << endl << j << endl << k << endl; exit(0); } } } } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int a, b, c, d; cin >> c >> b >> a >> d; int x, y, z; x = -1, y = -1, z = -1; int j = 0; int arr[100], brr[100], crr[100]; for (int i = a; i <= 2 * a; i++) { if (i <= 2 * d && i >= d) { x = i; arr[j] = i; j++; } } int sz1 = j; j = 0; for (int i = b; i <= 2 * b; i++) { if (i > 2 * d && i >= d) { y = i; brr[j] = i; j++; } } int sz2 = j; j = 0; for (int i = c; i <= 2 * c; i++) { if (i > 2 * d && i >= d) { z = i; crr[j] = i; j++; } } int sz3 = j; int f = 0; for (int i = sz1 - 1; i >= 0; i--) { for (j = sz2 - 1; j >= 0; j--) { for (int k = sz3 - 1; k >= 0; k--) { if (crr[k] > brr[j] && brr[j] > arr[i]) { x = arr[i]; y = brr[j]; z = crr[k]; f = 1; break; } } if (f == 1) break; } if (f == 1) break; } if (x == -1 || y == -1 || z == -1 || f == 0) { cout << "-1"; } else { cout << z << endl << y << endl << x << endl; } return 0; }
### Prompt Create a solution in CPP for the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int a, b, c, d; cin >> c >> b >> a >> d; int x, y, z; x = -1, y = -1, z = -1; int j = 0; int arr[100], brr[100], crr[100]; for (int i = a; i <= 2 * a; i++) { if (i <= 2 * d && i >= d) { x = i; arr[j] = i; j++; } } int sz1 = j; j = 0; for (int i = b; i <= 2 * b; i++) { if (i > 2 * d && i >= d) { y = i; brr[j] = i; j++; } } int sz2 = j; j = 0; for (int i = c; i <= 2 * c; i++) { if (i > 2 * d && i >= d) { z = i; crr[j] = i; j++; } } int sz3 = j; int f = 0; for (int i = sz1 - 1; i >= 0; i--) { for (j = sz2 - 1; j >= 0; j--) { for (int k = sz3 - 1; k >= 0; k--) { if (crr[k] > brr[j] && brr[j] > arr[i]) { x = arr[i]; y = brr[j]; z = crr[k]; f = 1; break; } } if (f == 1) break; } if (f == 1) break; } if (x == -1 || y == -1 || z == -1 || f == 0) { cout << "-1"; } else { cout << z << endl << y << endl << x << endl; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v4; scanf("%d%d%d%d", &v1, &v2, &v3, &v4); if (2 * v3 < v4 || v1 <= v4 || v2 <= v4 || 2 * v4 < v3) { printf("-1\n"); } else { printf("%d\n%d\n", 2 * v1, 2 * v2); if (v4 >= v3) printf("%d\n", 2 * v3); else { printf("%d\n", v3); } } return 0; }
### Prompt Create a solution in Cpp for the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v4; scanf("%d%d%d%d", &v1, &v2, &v3, &v4); if (2 * v3 < v4 || v1 <= v4 || v2 <= v4 || 2 * v4 < v3) { printf("-1\n"); } else { printf("%d\n%d\n", 2 * v1, 2 * v2); if (v4 >= v3) printf("%d\n", 2 * v3); else { printf("%d\n", v3); } } return 0; } ```
#include <bits/stdc++.h> using namespace std; int v1, v2, v3, vm; int main() { scanf("%d %d %d %d", &v1, &v2, &v3, &vm); for (int s1 = max(2 * vm + 1, v1); s1 <= 2 * v1; s1++) for (int s2 = max(2 * vm + 1, v2); s2 < s1 && s2 <= 2 * v2; s2++) for (int s3 = max(vm, v3); s3 < s2 && s3 <= 2 * v3 && s3 <= 2 * vm; s3++) { printf("%d\n%d\n%d\n", s1, s2, s3); return 0; } printf("-1\n"); return 0; }
### Prompt Generate a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int v1, v2, v3, vm; int main() { scanf("%d %d %d %d", &v1, &v2, &v3, &vm); for (int s1 = max(2 * vm + 1, v1); s1 <= 2 * v1; s1++) for (int s2 = max(2 * vm + 1, v2); s2 < s1 && s2 <= 2 * v2; s2++) for (int s3 = max(vm, v3); s3 < s2 && s3 <= 2 * v3 && s3 <= 2 * vm; s3++) { printf("%d\n%d\n%d\n", s1, s2, s3); return 0; } printf("-1\n"); return 0; } ```
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; if (vm > 2 * v3 || vm < v3 / 2 + (v3 & 1) || vm >= v2) cout << -1, exit(0); cout << 2 * v1 << endl << 2 * v2 << endl << max(vm, v3); return 0; }
### Prompt Create a solution in Cpp for the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; if (vm > 2 * v3 || vm < v3 / 2 + (v3 & 1) || vm >= v2) cout << -1, exit(0); cout << 2 * v1 << endl << 2 * v2 << endl << max(vm, v3); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (c > 2 * d || d > 2 * c || d >= b) cout << -1 << endl; else cout << 2 * a << endl << 2 * b << endl << max(c, d); }
### Prompt Please formulate a Cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (c > 2 * d || d > 2 * c || d >= b) cout << -1 << endl; else cout << 2 * a << endl << 2 * b << endl << max(c, d); } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, max = 0; scanf("%d %d %d %d", &a, &b, &c, &d); if (d < a && d < b && 2 * d >= c && d <= 2 * c) { if (c >= d) max = c; else max = d; printf("%d %d %d", 2 * a, 2 * b, max); } else { printf("%d", -1); } }
### Prompt Please create a solution in cpp to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, max = 0; scanf("%d %d %d %d", &a, &b, &c, &d); if (d < a && d < b && 2 * d >= c && d <= 2 * c) { if (c >= d) max = c; else max = d; printf("%d %d %d", 2 * a, 2 * b, max); } else { printf("%d", -1); } } ```
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const int INF = 1e9 + 7; const int N = 2e5 + 7; const int M = 1e6 + 7; signed main() { ios::sync_with_stdio(false); int fa, ma, son, sb; cin >> fa >> ma >> son >> sb; int lim[7]; for (int c3 = max(son, sb); c3 <= min(2 * son, 2 * sb); c3++) for (int c2 = max(ma, max(c3 + 1, 2 * sb + 1)); c2 <= 2 * ma; c2++) for (int c1 = max(fa, max(c2 + 1, 2 * sb + 1)); c3 <= 2 * fa; c3++) { cout << c1 << "\n" << c2 << "\n" << c3 << "\n"; return 0; } cout << "-1\n"; return 0; }
### Prompt Develop a solution in Cpp to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const int INF = 1e9 + 7; const int N = 2e5 + 7; const int M = 1e6 + 7; signed main() { ios::sync_with_stdio(false); int fa, ma, son, sb; cin >> fa >> ma >> son >> sb; int lim[7]; for (int c3 = max(son, sb); c3 <= min(2 * son, 2 * sb); c3++) for (int c2 = max(ma, max(c3 + 1, 2 * sb + 1)); c2 <= 2 * ma; c2++) for (int c1 = max(fa, max(c2 + 1, 2 * sb + 1)); c3 <= 2 * fa; c3++) { cout << c1 << "\n" << c2 << "\n" << c3 << "\n"; return 0; } cout << "-1\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; if (v3 > 2 * vm || vm > 2 * v3 || vm >= v2) cout << -1; else cout << 2 * v1 << endl << 2 * v2 << endl << max(v3, vm); return 0; }
### Prompt In cpp, your task is to solve the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; if (v3 > 2 * vm || vm > 2 * v3 || vm >= v2) cout << -1; else cout << 2 * v1 << endl << 2 * v2 << endl << max(v3, vm); return 0; } ```
#include <bits/stdc++.h> using namespace std; int v[4]; int main() { for (int i = 0; i < 4; ++i) scanf("%d", v + i); int mn = min(v[2], v[3]); int mx = max(v[2], v[3]); int c = mx; int b = max(v[1], 2 * c + 1); int a = max(v[0], b + 1); if (mx <= 2 * mn && v[1] * 2 >= b && v[0] * 2 >= a) { printf("%d\n%d\n%d\n", a, b, c); } else puts("-1"); return 0; }
### Prompt Construct a cpp code solution to the problem outlined: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int v[4]; int main() { for (int i = 0; i < 4; ++i) scanf("%d", v + i); int mn = min(v[2], v[3]); int mx = max(v[2], v[3]); int c = mx; int b = max(v[1], 2 * c + 1); int a = max(v[0], b + 1); if (mx <= 2 * mn && v[1] * 2 >= b && v[0] * 2 >= a) { printf("%d\n%d\n%d\n", a, b, c); } else puts("-1"); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v4, ans; scanf("%d %d %d %d", &v1, &v2, &v3, &v4); if (v4 > v3 * 2 || v3 > v4 * 2 || v4 >= v1 || v4 >= v2) { printf("-1"); return 0; } ans = max(v3, v4); printf("%d %d %d", v1 * 2, v2 * 2, ans); }
### Prompt Your challenge is to write a cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v4, ans; scanf("%d %d %d %d", &v1, &v2, &v3, &v4); if (v4 > v3 * 2 || v3 > v4 * 2 || v4 >= v1 || v4 >= v2) { printf("-1"); return 0; } ans = max(v3, v4); printf("%d %d %d", v1 * 2, v2 * 2, ans); } ```
#include <bits/stdc++.h> using namespace std; int V1, V2, V3, T1, T2, T3, Vm; int main() { cin >> V1 >> V2 >> V3 >> Vm; if (V3 > 2 * Vm || Vm > 2 * V3) { cout << -1; return 0; } T3 = max(Vm, V3); if (T3 >= V2) { cout << -1; return 0; } T2 = min(2 * V2, max(V2, 2 * T3 + 1)); T1 = min(2 * V1, max(V1, T2 + 1)); cout << T1 << endl << T2 << endl << T3; return 0; }
### Prompt Generate a cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int V1, V2, V3, T1, T2, T3, Vm; int main() { cin >> V1 >> V2 >> V3 >> Vm; if (V3 > 2 * Vm || Vm > 2 * V3) { cout << -1; return 0; } T3 = max(Vm, V3); if (T3 >= V2) { cout << -1; return 0; } T2 = min(2 * V2, max(V2, 2 * T3 + 1)); T1 = min(2 * V1, max(V1, T2 + 1)); cout << T1 << endl << T2 << endl << T3; return 0; } ```
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long int INFL = 0x3f3f3f3f3f3f3f3f; const double pi = atan(1.0) * 4.0; const int N = 0; int main(void) { ios_base::sync_with_stdio(false); int a, b, c, d; cin >> a >> b >> c >> d; int ca = 2 * a; int cb = 2 * b; int cc = min(2 * c, 2 * d); if (cc >= c && 2 * c >= cc && cc >= d && 2 * d >= cc && 2 * d < cb) { cout << ca << endl; cout << cb << endl; cout << cc << endl; } else cout << -1 << endl; return 0; }
### Prompt In CPP, your task is to solve the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long int INFL = 0x3f3f3f3f3f3f3f3f; const double pi = atan(1.0) * 4.0; const int N = 0; int main(void) { ios_base::sync_with_stdio(false); int a, b, c, d; cin >> a >> b >> c >> d; int ca = 2 * a; int cb = 2 * b; int cc = min(2 * c, 2 * d); if (cc >= c && 2 * c >= cc && cc >= d && 2 * d >= cc && 2 * d < cb) { cout << ca << endl; cout << cb << endl; cout << cc << endl; } else cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d); if (d > 2 * c || c > 2 * d || d >= b) printf("-1"); else printf("%d\n%d\n%d", 2 * a, 2 * b, max(c, d)); return 0; }
### Prompt Your challenge is to write a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d); if (d > 2 * c || c > 2 * d || d >= b) printf("-1"); else printf("%d\n%d\n%d", 2 * a, 2 * b, max(c, d)); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; while (~scanf("%d%d%d%d", &v1, &v2, &v3, &vm)) { if (2 * vm >= v3 && vm <= 2 * v3 && vm < v2) { int a1 = 2 * v1, a2 = 2 * v2, a3 = (vm <= v3) ? v3 : vm; printf("%d\n%d\n%d\n", a1, a2, a3); } else printf("-1\n"); } return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; while (~scanf("%d%d%d%d", &v1, &v2, &v3, &vm)) { if (2 * vm >= v3 && vm <= 2 * v3 && vm < v2) { int a1 = 2 * v1, a2 = 2 * v2, a3 = (vm <= v3) ? v3 : vm; printf("%d\n%d\n%d\n", a1, a2, a3); } else printf("-1\n"); } return 0; } ```
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const int inf = 0x3f3f3f3f; const double eps = 1e-8; const double pi = acos(-1.0); int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (d * 2 >= c && c * 2 >= d && d < b) { int x = max(c, d); int y = max(x * 2 + 1, b); int z = max(y + 1, a); cout << z << "\n" << y << "\n" << x << endl; } else cout << "-1" << endl; return 0; }
### Prompt Develop a solution in Cpp to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const int inf = 0x3f3f3f3f; const double eps = 1e-8; const double pi = acos(-1.0); int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (d * 2 >= c && c * 2 >= d && d < b) { int x = max(c, d); int y = max(x * 2 + 1, b); int z = max(y + 1, a); cout << z << "\n" << y << "\n" << x << endl; } else cout << "-1" << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9; const long long inf64 = 1e18; const long long MOD = inf + 7; const long double PI = acos(-1.0); int32_t main() { ios::sync_with_stdio(false), cin.tie(nullptr); ; long long a, b, c, d; cin >> a >> b >> c >> d; for (long long i = c; i <= 2 * c; i++) { if (d <= i && 2 * d >= i && b > i) { cout << 2 * a << endl << 2 * b << endl << i; return 0; } } cout << -1; }
### Prompt Please formulate a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const long long inf = 1e9; const long long inf64 = 1e18; const long long MOD = inf + 7; const long double PI = acos(-1.0); int32_t main() { ios::sync_with_stdio(false), cin.tie(nullptr); ; long long a, b, c, d; cin >> a >> b >> c >> d; for (long long i = c; i <= 2 * c; i++) { if (d <= i && 2 * d >= i && b > i) { cout << 2 * a << endl << 2 * b << endl << i; return 0; } } cout << -1; } ```
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, v[4], m = 4; for (i = 0; i < m; i++) cin >> v[i]; int masha = v[3]; for (k = v[0]; k <= 2 * v[0]; k++) for (j = v[1]; j <= 2 * v[1]; j++) for (i = masha; i <= 2 * v[2]; i++) if (i <= 2 * masha && j > 2 * masha && k > 2 * masha && k > j && j > i && i >= v[2]) { cout << k << ' ' << j << ' ' << i << endl; return 0; } cout << -1 << endl; return 0; }
### Prompt Create a solution in CPP for the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int i, j, k, v[4], m = 4; for (i = 0; i < m; i++) cin >> v[i]; int masha = v[3]; for (k = v[0]; k <= 2 * v[0]; k++) for (j = v[1]; j <= 2 * v[1]; j++) for (i = masha; i <= 2 * v[2]; i++) if (i <= 2 * masha && j > 2 * masha && k > 2 * masha && k > j && j > i && i >= v[2]) { cout << k << ' ' << j << ' ' << i << endl; return 0; } cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; void build() {} const int mod = 1000000007, N = 200005; const long long inf = 1e18; void preprocess() { return; } int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); build(); preprocess(); int v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; int c1, c2, c3; int flag = 1; if (v4 > 2 * v3) flag = 0; c3 = max(v4, v3); if (c3 > 2 * v4) flag = 0; if (2 * v2 <= 2 * v4) flag = 0; c2 = 2 * v2; c1 = 2 * v1; if (flag == 0) cout << -1; else cout << c1 << " " << c2 << " " << c3; return 0; }
### Prompt Generate a cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; void build() {} const int mod = 1000000007, N = 200005; const long long inf = 1e18; void preprocess() { return; } int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); build(); preprocess(); int v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; int c1, c2, c3; int flag = 1; if (v4 > 2 * v3) flag = 0; c3 = max(v4, v3); if (c3 > 2 * v4) flag = 0; if (2 * v2 <= 2 * v4) flag = 0; c2 = 2 * v2; c1 = 2 * v1; if (flag == 0) cout << -1; else cout << c1 << " " << c2 << " " << c3; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; bool flag = 0; for (int i = a; i <= 2 * a; i++) { for (int j = b; j <= 2 * b; j++) { for (int k = c; k <= 2 * c; k++) { if (i > j && j > k && k >= d && k <= 2 * d && j > 2 * d) { cout << i << endl << j << endl << k << endl; return 0; } } } } cout << -1 << endl; return 0; }
### Prompt Generate a Cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; bool flag = 0; for (int i = a; i <= 2 * a; i++) { for (int j = b; j <= 2 * b; j++) { for (int k = c; k <= 2 * c; k++) { if (i > j && j > k && k >= d && k <= 2 * d && j > 2 * d) { cout << i << endl << j << endl << k << endl; return 0; } } } } cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; bool judge(int a, int b) { return a <= b && a * 2 >= b; } int main(void) { int v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; for (int i = 1; i <= 300; ++i) { for (int j = 1; j < i; ++j) { for (int k = 1; k < j; ++k) { if (judge(v1, i) && judge(v2, j) && judge(v3, k) && (v4 <= k && (v4 * 2 >= k) && (v4 * 2 < j))) { cout << i << endl << j << endl << k; return 0; } } } } cout << -1; }
### Prompt Develop a solution in cpp to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; bool judge(int a, int b) { return a <= b && a * 2 >= b; } int main(void) { int v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; for (int i = 1; i <= 300; ++i) { for (int j = 1; j < i; ++j) { for (int k = 1; k < j; ++k) { if (judge(v1, i) && judge(v2, j) && judge(v3, k) && (v4 <= k && (v4 * 2 >= k) && (v4 * 2 < j))) { cout << i << endl << j << endl << k; return 0; } } } } cout << -1; } ```
#include <bits/stdc++.h> using namespace std; int v1, v2, v3, vm; int l[5], r[5]; int main() { while (~scanf("%d%d%d%d", &v1, &v2, &v3, &vm)) { l[1] = v1; r[1] = 2 * v1; l[2] = v2; r[2] = 2 * v2; l[3] = v3; r[3] = 2 * v3; int a1 = -1, a2 = -1, a3 = -1; for (int i = r[1]; i >= l[1] && a1 == -1; i--) { if (vm <= i && 2 * vm < i) a1 = i; } for (int i = r[2]; i >= l[2] && a2 == -1; i--) { if (vm <= i && 2 * vm < i) a2 = i; } for (int i = l[3]; i <= r[3] && a3 == -1; i++) { if (vm <= i && 2 * vm >= i) a3 = i; } if (a1 != -1 && a2 != -1 && a3 != -1) printf("%d\n%d\n%d\n", a1, a2, a3); else puts("-1"); } return 0; }
### Prompt Develop a solution in Cpp to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int v1, v2, v3, vm; int l[5], r[5]; int main() { while (~scanf("%d%d%d%d", &v1, &v2, &v3, &vm)) { l[1] = v1; r[1] = 2 * v1; l[2] = v2; r[2] = 2 * v2; l[3] = v3; r[3] = 2 * v3; int a1 = -1, a2 = -1, a3 = -1; for (int i = r[1]; i >= l[1] && a1 == -1; i--) { if (vm <= i && 2 * vm < i) a1 = i; } for (int i = r[2]; i >= l[2] && a2 == -1; i--) { if (vm <= i && 2 * vm < i) a2 = i; } for (int i = l[3]; i <= r[3] && a3 == -1; i++) { if (vm <= i && 2 * vm >= i) a3 = i; } if (a1 != -1 && a2 != -1 && a3 != -1) printf("%d\n%d\n%d\n", a1, a2, a3); else puts("-1"); } return 0; } ```
#include <bits/stdc++.h> using namespace std; void readi(int &x) { int v = 0, f = 1; char c = getchar(); while (!isdigit(c) && c != '-') c = getchar(); if (c == '-') f = -1; else v = v * 10 + c - '0'; while (isdigit(c = getchar())) v = v * 10 + c - '0'; x = v * f; } void readll(long long &x) { long long v = 0ll, f = 1ll; char c = getchar(); while (!isdigit(c) && c != '-') c = getchar(); if (c == '-') f = -1; else v = v * 10 + c - '0'; while (isdigit(c = getchar())) v = v * 10 + c - '0'; x = v * f; } void readc(char &x) { char c; while ((c = getchar()) == ' ') ; x = c; } void writes(string s) { puts(s.c_str()); } void writeln() { writes(""); } void writei(int x) { if (!x) putchar('0'); char a[25]; int top = 0; while (x) { a[++top] = (x % 10) + '0'; x /= 10; } while (top) { putchar(a[top]); top--; } } void writell(long long x) { if (!x) putchar('0'); char a[25]; int top = 0; while (x) { a[++top] = (x % 10) + '0'; x /= 10; } while (top) { putchar(a[top]); top--; } } long long qp(long long x, long long y) { if (y == 0) return 1; if (y == 1) return x; long long z = qp(x, y / 2); z = z * z % 1000000007; if (y & 1) z = z * x % 1000000007; return z; } int a, b, c, d, i, j, k; int main() { cin >> a >> b >> c >> d; for (i = 1; i <= 200; i++) { for (j = 1; j < i; j++) { for (k = 1; k < j; k++) { if (a <= i && a * 2 >= i && b <= j && 2 * b >= j && c <= k && 2 * c >= k && d <= k && 2 * d >= k && 2 * d < j) { cout << i << endl << j << endl << k << endl; return 0; } } } } cout << -1; return 0; }
### Prompt In Cpp, your task is to solve the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; void readi(int &x) { int v = 0, f = 1; char c = getchar(); while (!isdigit(c) && c != '-') c = getchar(); if (c == '-') f = -1; else v = v * 10 + c - '0'; while (isdigit(c = getchar())) v = v * 10 + c - '0'; x = v * f; } void readll(long long &x) { long long v = 0ll, f = 1ll; char c = getchar(); while (!isdigit(c) && c != '-') c = getchar(); if (c == '-') f = -1; else v = v * 10 + c - '0'; while (isdigit(c = getchar())) v = v * 10 + c - '0'; x = v * f; } void readc(char &x) { char c; while ((c = getchar()) == ' ') ; x = c; } void writes(string s) { puts(s.c_str()); } void writeln() { writes(""); } void writei(int x) { if (!x) putchar('0'); char a[25]; int top = 0; while (x) { a[++top] = (x % 10) + '0'; x /= 10; } while (top) { putchar(a[top]); top--; } } void writell(long long x) { if (!x) putchar('0'); char a[25]; int top = 0; while (x) { a[++top] = (x % 10) + '0'; x /= 10; } while (top) { putchar(a[top]); top--; } } long long qp(long long x, long long y) { if (y == 0) return 1; if (y == 1) return x; long long z = qp(x, y / 2); z = z * z % 1000000007; if (y & 1) z = z * x % 1000000007; return z; } int a, b, c, d, i, j, k; int main() { cin >> a >> b >> c >> d; for (i = 1; i <= 200; i++) { for (j = 1; j < i; j++) { for (k = 1; k < j; k++) { if (a <= i && a * 2 >= i && b <= j && 2 * b >= j && c <= k && 2 * c >= k && d <= k && 2 * d >= k && 2 * d < j) { cout << i << endl << j << endl << k << endl; return 0; } } } } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int a, b, c, d; cin >> a >> b >> c >> d; a *= 2; b *= 2; if (2 * d >= a || 2 * d >= b || 2 * c < d || 2 * d < c) { cout << -1 << endl; return 0; } else { cout << a << endl; cout << b << endl; long long int temp = min(c, d); cout << 2 * temp << endl; } return 0; }
### Prompt Generate a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int a, b, c, d; cin >> a >> b >> c >> d; a *= 2; b *= 2; if (2 * d >= a || 2 * d >= b || 2 * c < d || 2 * d < c) { cout << -1 << endl; return 0; } else { cout << a << endl; cout << b << endl; long long int temp = min(c, d); cout << 2 * temp << endl; } return 0; } ```
#include <bits/stdc++.h> long long inf = 1LL << 60; long long mod = 1000000007; double pi = acos(-1.0); using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; vector<int> ans; for (int i = v3; i <= 2 * v3; i++) { if (i >= vm && 2 * vm >= i) { ans.push_back(i); break; } } if (ans.size() == 0) { cout << -1; return 0; } for (int i = max(ans[0] + 1, v2); i <= 2 * v2; i++) { if (i >= vm && 2 * vm < i) { ans.push_back(i); break; } } if (ans.size() == 1) { cout << -1; return 0; } for (int i = max(ans[1] + 1, v1); i <= 2 * v1; i++) { if (i >= vm && 2 * vm < i) { ans.push_back(i); break; } } if (ans.size() == 3) { cout << ans[2] << endl; cout << ans[1] << endl; cout << ans[0]; return 0; } cout << -1; return 0; }
### Prompt Your task is to create a cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> long long inf = 1LL << 60; long long mod = 1000000007; double pi = acos(-1.0); using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; vector<int> ans; for (int i = v3; i <= 2 * v3; i++) { if (i >= vm && 2 * vm >= i) { ans.push_back(i); break; } } if (ans.size() == 0) { cout << -1; return 0; } for (int i = max(ans[0] + 1, v2); i <= 2 * v2; i++) { if (i >= vm && 2 * vm < i) { ans.push_back(i); break; } } if (ans.size() == 1) { cout << -1; return 0; } for (int i = max(ans[1] + 1, v1); i <= 2 * v1; i++) { if (i >= vm && 2 * vm < i) { ans.push_back(i); break; } } if (ans.size() == 3) { cout << ans[2] << endl; cout << ans[1] << endl; cout << ans[0]; return 0; } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; for (int i = 1; i <= 200; i++) { for (int j = 1; j <= 200; j++) { for (int k = 1; k <= 200; k++) { if (v1 <= i && v2 <= j && v3 <= k && 2 * v1 >= i && 2 * v2 >= j && 2 * v3 >= k && v4 <= i && v4 <= j && v4 <= k && 2 * v4 >= k && 2 * v4 < i && 2 * v4 < j && i > j && j > k) { cout << i << endl; cout << j << endl; cout << k << endl; return 0; } } } } cout << -1 << endl; return 0; }
### Prompt Please formulate a cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; for (int i = 1; i <= 200; i++) { for (int j = 1; j <= 200; j++) { for (int k = 1; k <= 200; k++) { if (v1 <= i && v2 <= j && v3 <= k && 2 * v1 >= i && 2 * v2 >= j && 2 * v3 >= k && v4 <= i && v4 <= j && v4 <= k && 2 * v4 >= k && 2 * v4 < i && 2 * v4 < j && i > j && j > k) { cout << i << endl; cout << j << endl; cout << k << endl; return 0; } } } } cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int V1, V2, V3, Vm; int main() { ios::sync_with_stdio(0); cin.tie(NULL); cin >> V1 >> V2 >> V3 >> Vm; for (int i = (V1); i <= (2 * V1); i++) for (int j = (V2); j <= (2 * V2); j++) for (int k = (V3); k <= (2 * V3); k++) { if (i > j && j > k && Vm <= k && k <= 2 * Vm && 2 * Vm < i && 2 * Vm < j) { cout << i << endl; cout << j << endl; cout << k << endl; return 0; } } cout << -1; return 0; }
### Prompt Your task is to create a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int V1, V2, V3, Vm; int main() { ios::sync_with_stdio(0); cin.tie(NULL); cin >> V1 >> V2 >> V3 >> Vm; for (int i = (V1); i <= (2 * V1); i++) for (int j = (V2); j <= (2 * V2); j++) for (int k = (V3); k <= (2 * V3); k++) { if (i > j && j > k && Vm <= k && k <= 2 * Vm && 2 * Vm < i && 2 * Vm < j) { cout << i << endl; cout << j << endl; cout << k << endl; return 0; } } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, sg, i, j, k; cin >> v1 >> v2 >> v3 >> sg; for (i = 2 * v1; i; i--) for (j = min(2 * v2, i - 1); j; j--) for (k = i - 1; k; k--) if (max(max(sg, v1), 2 * sg + 1) <= i && max(max(sg, v2), 2 * sg + 1) <= j && max(sg, v3) <= k && k <= min(2 * sg, 2 * v3)) { cout << i << endl << j << endl << k << endl; return 0; } cout << -1 << endl; return 0; }
### Prompt Please provide a CPP coded solution to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, sg, i, j, k; cin >> v1 >> v2 >> v3 >> sg; for (i = 2 * v1; i; i--) for (j = min(2 * v2, i - 1); j; j--) for (k = i - 1; k; k--) if (max(max(sg, v1), 2 * sg + 1) <= i && max(max(sg, v2), 2 * sg + 1) <= j && max(sg, v3) <= k && k <= min(2 * sg, 2 * v3)) { cout << i << endl << j << endl << k << endl; return 0; } cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int jud(int person, int family) { for (int i = 2 * family; i >= family; i--) { if (person <= i && 2 * person >= i) return i; } return 0; } int get_in(int person, int family) { for (int i = 2 * family; i >= family; i--) { if (person <= i && 2 * person < i) { return i; } } return 0; } int ans[10]; int main() { int v[10]; for (int i = 1; i <= 4; i++) { cin >> v[i]; } ans[1] = get_in(v[4], v[1]); ans[2] = get_in(v[4], v[2]); ans[3] = jud(v[4], v[3]); if (ans[1] && ans[2] && ans[3] && ans[1] > ans[2] && ans[2] > ans[3]) { cout << ans[1] << endl << ans[2] << endl << ans[3] << endl; } else { cout << -1 << endl; } }
### Prompt Your task is to create a cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int jud(int person, int family) { for (int i = 2 * family; i >= family; i--) { if (person <= i && 2 * person >= i) return i; } return 0; } int get_in(int person, int family) { for (int i = 2 * family; i >= family; i--) { if (person <= i && 2 * person < i) { return i; } } return 0; } int ans[10]; int main() { int v[10]; for (int i = 1; i <= 4; i++) { cin >> v[i]; } ans[1] = get_in(v[4], v[1]); ans[2] = get_in(v[4], v[2]); ans[3] = jud(v[4], v[3]); if (ans[1] && ans[2] && ans[3] && ans[1] > ans[2] && ans[2] > ans[3]) { cout << ans[1] << endl << ans[2] << endl << ans[3] << endl; } else { cout << -1 << endl; } } ```
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int INF = 0x3f3f3f3f; const double eps = 1e-8; const long long mod = 10007; const int N = 3000; int main() { int v[10]; int ans[10]; for (int i = 1; i <= 4; i++) { scanf("%d", &v[i]); ans[i] = v[i]; } if (v[3] * 2 < v[4] || v[1] <= v[4] || v[2] <= v[4] || v[3] > 2 * v[4]) { printf("-1"); } else { ans[3] = max(v[4], v[3]); ans[2] = max(v[4] * 2 + 1, v[2]); ans[1] = max(ans[2] + 1, v[1]); for (int i = 1; i <= 3; i++) { printf("%d\n", ans[i]); } } return 0; }
### Prompt Construct a CPP code solution to the problem outlined: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int INF = 0x3f3f3f3f; const double eps = 1e-8; const long long mod = 10007; const int N = 3000; int main() { int v[10]; int ans[10]; for (int i = 1; i <= 4; i++) { scanf("%d", &v[i]); ans[i] = v[i]; } if (v[3] * 2 < v[4] || v[1] <= v[4] || v[2] <= v[4] || v[3] > 2 * v[4]) { printf("-1"); } else { ans[3] = max(v[4], v[3]); ans[2] = max(v[4] * 2 + 1, v[2]); ans[1] = max(ans[2] + 1, v[1]); for (int i = 1; i <= 3; i++) { printf("%d\n", ans[i]); } } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; while (scanf("%d%d%d%d", &a, &b, &c, &d) == 4) { int L1 = c, R1 = 2 * c, L2 = d, R2 = 2 * d; if (L1 <= R2 && L2 <= R1 && R2 < 2 * b) { int t1 = max(L1, L2); printf("%d %d %d\n", 2 * a, 2 * b, t1); } else printf("-1\n"); } return 0; }
### Prompt Generate a Cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; while (scanf("%d%d%d%d", &a, &b, &c, &d) == 4) { int L1 = c, R1 = 2 * c, L2 = d, R2 = 2 * d; if (L1 <= R2 && L2 <= R1 && R2 < 2 * b) { int t1 = max(L1, L2); printf("%d %d %d\n", 2 * a, 2 * b, t1); } else printf("-1\n"); } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int a, b, c, m; int flag = 0; int c1 = 0, c2 = 0, c3 = 0; int t; cin >> a >> b >> c >> m; t = 0; for (int i = min(c, m); i <= 2 * c && i <= 2 * m; i++) { if ((m <= i && 2 * m >= i) && (c <= i && 2 * c >= i)) { t = 1; c3 = i; break; } } if (t == 0) { flag = 1; } if (flag == 0) { t = 0; for (int i = b; i <= 2 * b; i++) { if ((m <= i) && (b <= i && 2 * b >= i) && i > c3 && (2 * m < i)) { t = 1; c2 = i; break; } } if (t == 0) { flag = 1; } } if (flag == 0) { t = 0; for (int i = a; i <= 2 * a; i++) { if ((m <= i) && (a <= i && 2 * a >= i) && i > c2 && (2 * m < i)) { t = 1; c1 = i; break; } } if (t == 0) { flag = 1; } } if (flag == 1) { cout << "-1\n"; } else { cout << c1 << '\n' << c2 << '\n' << c3 << '\n'; } return 0; }
### Prompt Develop a solution in CPP to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int a, b, c, m; int flag = 0; int c1 = 0, c2 = 0, c3 = 0; int t; cin >> a >> b >> c >> m; t = 0; for (int i = min(c, m); i <= 2 * c && i <= 2 * m; i++) { if ((m <= i && 2 * m >= i) && (c <= i && 2 * c >= i)) { t = 1; c3 = i; break; } } if (t == 0) { flag = 1; } if (flag == 0) { t = 0; for (int i = b; i <= 2 * b; i++) { if ((m <= i) && (b <= i && 2 * b >= i) && i > c3 && (2 * m < i)) { t = 1; c2 = i; break; } } if (t == 0) { flag = 1; } } if (flag == 0) { t = 0; for (int i = a; i <= 2 * a; i++) { if ((m <= i) && (a <= i && 2 * a >= i) && i > c2 && (2 * m < i)) { t = 1; c1 = i; break; } } if (t == 0) { flag = 1; } } if (flag == 1) { cout << "-1\n"; } else { cout << c1 << '\n' << c2 << '\n' << c3 << '\n'; } return 0; } ```
#include <bits/stdc++.h> int main() { int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d); for (int i = a; i <= 2 * a; ++i) for (int j = b; j <= 2 * b && j < i; ++j) for (int k = c; k <= 2 * c && k < j; ++k) if (d <= i && d <= j && d <= k && d * 2 >= k && d * 2 < j && d * 2 < i) { printf("%d\n%d\n%d", i, j, k); return 0; } puts("-1"); }
### Prompt Your challenge is to write a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> int main() { int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d); for (int i = a; i <= 2 * a; ++i) for (int j = b; j <= 2 * b && j < i; ++j) for (int k = c; k <= 2 * c && k < j; ++k) if (d <= i && d <= j && d <= k && d * 2 >= k && d * 2 < j && d * 2 < i) { printf("%d\n%d\n%d", i, j, k); return 0; } puts("-1"); } ```
#include <bits/stdc++.h> using namespace std; void read(bool out = 0) {} bool can(long long man, long long car) { return man <= car; } bool like(long long man, long long car) { return 2 * man >= car; } int main() { long long a, b, c, k; cin >> a >> b >> c >> k; for (int i = 1; i < 201; i++) for (int j = 1; j < 201; j++) for (int l = 1; l < 201; l++) { if (i > j && j > l) { if (can(a, i) && like(a, i)) { if (can(b, j) && like(b, j)) { if (can(c, l) && like(c, l)) { if (can(k, i) && can(k, j) && can(k, l)) { if (like(k, l) && !like(k, i) && !like(k, j)) { return cout << i << "\n" << j << "\n" << l << "\n", 0; } } } } } } } cout << -1; }
### Prompt In CPP, your task is to solve the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; void read(bool out = 0) {} bool can(long long man, long long car) { return man <= car; } bool like(long long man, long long car) { return 2 * man >= car; } int main() { long long a, b, c, k; cin >> a >> b >> c >> k; for (int i = 1; i < 201; i++) for (int j = 1; j < 201; j++) for (int l = 1; l < 201; l++) { if (i > j && j > l) { if (can(a, i) && like(a, i)) { if (can(b, j) && like(b, j)) { if (can(c, l) && like(c, l)) { if (can(k, i) && can(k, j) && can(k, l)) { if (like(k, l) && !like(k, i) && !like(k, j)) { return cout << i << "\n" << j << "\n" << l << "\n", 0; } } } } } } } cout << -1; } ```
#include <bits/stdc++.h> using namespace std; int x, y; int ap[100005], b[20000001] = {0}; int main() { int b1, b2, b3, m; cin >> b1 >> b2 >> b3 >> m; for (int i = 0; i < 250; i++) { for (int j = 0; j < 250; j++) { for (int h = 0; h < 250; h++) { if (i >= max(b1, m) && j >= max(b2, m) && h >= max(b3, m)) { if (i <= 2 * b1 && j <= 2 * b2 && h <= 2 * b3) { if (i > 2 * m && j > 2 * m) { if (h <= 2 * m) { if (i > j && j > h) { cout << i << endl; cout << j << endl; cout << h << endl; return 0; } } } } } } } } cout << -1 << endl; return 0; }
### Prompt Construct a Cpp code solution to the problem outlined: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int x, y; int ap[100005], b[20000001] = {0}; int main() { int b1, b2, b3, m; cin >> b1 >> b2 >> b3 >> m; for (int i = 0; i < 250; i++) { for (int j = 0; j < 250; j++) { for (int h = 0; h < 250; h++) { if (i >= max(b1, m) && j >= max(b2, m) && h >= max(b3, m)) { if (i <= 2 * b1 && j <= 2 * b2 && h <= 2 * b3) { if (i > 2 * m && j > 2 * m) { if (h <= 2 * m) { if (i > j && j > h) { cout << i << endl; cout << j << endl; cout << h << endl; return 0; } } } } } } } } cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; const long long int INF = 1000000007; const int N = 100000 + 7; int main() { int a, b, c, d; cin >> a >> b >> c >> d; for (int i = 1; i <= 200; i++) { for (int j = 1; j < i; j++) { for (int k = 1; k < i; k++) { if (a <= i && i <= 2 * a && b <= j && j <= 2 * b && c <= k && k <= 2 * c && d <= k && k <= 2 * d && j > 2 * d) { cout << i << endl; cout << j << endl; cout << k << endl; return 0; } } } } cout << -1 << endl; return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const long long int INF = 1000000007; const int N = 100000 + 7; int main() { int a, b, c, d; cin >> a >> b >> c >> d; for (int i = 1; i <= 200; i++) { for (int j = 1; j < i; j++) { for (int k = 1; k < i; k++) { if (a <= i && i <= 2 * a && b <= j && j <= 2 * b && c <= k && k <= 2 * c && d <= k && k <= 2 * d && j > 2 * d) { cout << i << endl; cout << j << endl; cout << k << endl; return 0; } } } } cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; while (scanf("%d%d%d%d", &a, &b, &c, &d) == 4) { for (int i = a; i <= 2 * a; i++) { for (int j = b; j <= 2 * b && j < i; j++) { for (int k = c; k <= 2 * c && k < j; k++) { if (a <= i && b <= j && c <= k && 2 * a >= i && 2 * b >= j && 2 * c >= k && d <= j && d <= i && d <= k && 2 * d >= k && 2 * d < i && 2 * d < j) { cout << i << ' ' << j << ' ' << k << endl; goto OK; } } } } cout << -1 << endl; continue; OK: continue; } }
### Prompt Please provide a CPP coded solution to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; while (scanf("%d%d%d%d", &a, &b, &c, &d) == 4) { for (int i = a; i <= 2 * a; i++) { for (int j = b; j <= 2 * b && j < i; j++) { for (int k = c; k <= 2 * c && k < j; k++) { if (a <= i && b <= j && c <= k && 2 * a >= i && 2 * b >= j && 2 * c >= k && d <= j && d <= i && d <= k && 2 * d >= k && 2 * d < i && 2 * d < j) { cout << i << ' ' << j << ' ' << k << endl; goto OK; } } } } cout << -1 << endl; continue; OK: continue; } } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v4; scanf("%d%d%d%d", &v1, &v2, &v3, &v4); for (int a1 = 0; a1 <= 200; a1++) for (int b1 = 0; b1 < a1; b1++) for (int c1 = 0; c1 < b1; c1++) if (a1 >= v1 && b1 >= v2 && c1 >= v3 && a1 <= v1 * 2 && b1 <= v2 * 2 && c1 <= v3 * 2 && v4 <= a1 && v4 <= b1 && v4 <= c1 && v4 * 2 < a1 && v4 * 2 < b1 && v4 * 2 >= c1) { printf("%d\n%d\n%d\n", a1, b1, c1); return 0; } printf("-1\n"); return 0; }
### Prompt Generate a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v4; scanf("%d%d%d%d", &v1, &v2, &v3, &v4); for (int a1 = 0; a1 <= 200; a1++) for (int b1 = 0; b1 < a1; b1++) for (int c1 = 0; c1 < b1; c1++) if (a1 >= v1 && b1 >= v2 && c1 >= v3 && a1 <= v1 * 2 && b1 <= v2 * 2 && c1 <= v3 * 2 && v4 <= a1 && v4 <= b1 && v4 <= c1 && v4 * 2 < a1 && v4 * 2 < b1 && v4 * 2 >= c1) { printf("%d\n%d\n%d\n", a1, b1, c1); return 0; } printf("-1\n"); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(); cout.tie(); ; int v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; for (int i = 300; i >= 1; i--) { if (v1 <= i && 2 * v1 >= i) { for (int j = i - 1; j >= 1; j--) { if (v2 <= j && 2 * v2 >= j) { for (int q = j - 1; q >= 1; q--) { if (v3 <= q && 2 * v3 >= q) { if (v4 <= q && 2 * v4 >= q && 2 * v4 < j && 2 * v4 < i) { return cout << i << endl << j << endl << q, 0; } } } } } } } cout << -1; }
### Prompt Create a solution in CPP for the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(); cout.tie(); ; int v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; for (int i = 300; i >= 1; i--) { if (v1 <= i && 2 * v1 >= i) { for (int j = i - 1; j >= 1; j--) { if (v2 <= j && 2 * v2 >= j) { for (int q = j - 1; q >= 1; q--) { if (v3 <= q && 2 * v3 >= q) { if (v4 <= q && 2 * v4 >= q && 2 * v4 < j && 2 * v4 < i) { return cout << i << endl << j << endl << q, 0; } } } } } } } cout << -1; } ```
#include <bits/stdc++.h> using namespace std; long long sum(long long a) { return a * (a + 1) / 2; } int main() { int a, b, c, m; cin >> a >> b >> c >> m; for (int i = 1; i <= 200; i++) { for (int j = 1; j <= 200; j++) { for (int k = 1; k <= 200; k++) { if (i >= a && i <= 2 * a && j >= b && j <= 2 * b && k >= c && k <= 2 * c && k >= m && k <= 2 * m && i > j && j > k && i > 2 * m && j > 2 * m) { cout << i << endl << j << endl << k << endl; return 0; } } } } cout << -1 << endl; }
### Prompt Please provide a CPP coded solution to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long sum(long long a) { return a * (a + 1) / 2; } int main() { int a, b, c, m; cin >> a >> b >> c >> m; for (int i = 1; i <= 200; i++) { for (int j = 1; j <= 200; j++) { for (int k = 1; k <= 200; k++) { if (i >= a && i <= 2 * a && j >= b && j <= 2 * b && k >= c && k <= 2 * c && k >= m && k <= 2 * m && i > j && j > k && i > 2 * m && j > 2 * m) { cout << i << endl << j << endl << k << endl; return 0; } } } } cout << -1 << endl; } ```
#include <bits/stdc++.h> using namespace std; long long pwr(long long base, long long p, long long mod = 1000000000) { long long ans = 1; while (p) { if (p % 2 == 1) ans = (ans * base) % 1000000000; base = (base * base) % 1000000000; p /= 2; } return ans; } long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); } bool cmp(const pair<int, int> &a, const pair<int, int> &b) { return (a.first > b.first); } const long long N = 5e5 + 5; int main() { int p, m, s, ma; cin >> p >> m >> s >> ma; if (s > 2 * ma || 2 * s < ma || m <= ma) { cout << -1 << endl; } else { cout << 2 * p << endl << 2 * m << endl << max(s, ma) << endl; } return 0; }
### Prompt Construct a CPP code solution to the problem outlined: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long pwr(long long base, long long p, long long mod = 1000000000) { long long ans = 1; while (p) { if (p % 2 == 1) ans = (ans * base) % 1000000000; base = (base * base) % 1000000000; p /= 2; } return ans; } long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); } bool cmp(const pair<int, int> &a, const pair<int, int> &b) { return (a.first > b.first); } const long long N = 5e5 + 5; int main() { int p, m, s, ma; cin >> p >> m >> s >> ma; if (s > 2 * ma || 2 * s < ma || m <= ma) { cout << -1 << endl; } else { cout << 2 * p << endl << 2 * m << endl << max(s, ma) << endl; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int v1, v2, v3, vm; bool check(int i, int j, int k) { if (i >= max(v1, vm) && j >= max(v2, vm) && k >= max(v3, vm)) { if (i <= 2 * v1 && j <= 2 * v2 && k <= 2 * v3) { if (i > 2 * vm && j > 2 * vm) { if (k <= 2 * vm) { if (i > j && j > k) { return true; } else { return false; } } else { return false; } } else { return false; } } else { return false; } } else { return false; } } int main() { cin >> v1 >> v2 >> v3 >> vm; bool ans = false; for (int i = 1; i <= 200; i++) { for (int j = 1; j <= 200; j++) { for (int k = 0; k <= 200; k++) { if (check(i, j, k)) { cout << i << endl; cout << j << endl; cout << k << endl; ans = true; return 0; } } } } if (!ans) { cout << -1 << endl; } }
### Prompt Your challenge is to write a Cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int v1, v2, v3, vm; bool check(int i, int j, int k) { if (i >= max(v1, vm) && j >= max(v2, vm) && k >= max(v3, vm)) { if (i <= 2 * v1 && j <= 2 * v2 && k <= 2 * v3) { if (i > 2 * vm && j > 2 * vm) { if (k <= 2 * vm) { if (i > j && j > k) { return true; } else { return false; } } else { return false; } } else { return false; } } else { return false; } } else { return false; } } int main() { cin >> v1 >> v2 >> v3 >> vm; bool ans = false; for (int i = 1; i <= 200; i++) { for (int j = 1; j <= 200; j++) { for (int k = 0; k <= 200; k++) { if (check(i, j, k)) { cout << i << endl; cout << j << endl; cout << k << endl; ans = true; return 0; } } } } if (!ans) { cout << -1 << endl; } } ```
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; const int INF = INT_MAX; const long long INFLL = (long long)1e18; const double PI = acos(-1.0); template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } const int N = (int)1e5 + 5; const int P = 1 << 18; int a, b, c; int m; int main() { ios::sync_with_stdio(false); cout.setf(ios::fixed | ios::showpoint); cout.precision(8); cin >> a >> b >> c >> m; int A = a * 2, B = b * 2, C = c; if (m <= B && m * 2 >= B) return !printf("-1\n"); if (m > C * 2) return !printf("-1\n"); if (C % 2 == 1) C = C / 2 + 1; else C /= 2; if (m * 2 < C) return !printf("-1\n"); C = -1; for (int i = c; i <= c * 2; i++) { if (m <= i && 2 * m >= i) { C = i; break; } } if (C == -1) return !printf("-1\n"); cout << A << '\n' << B << '\n' << C << endl; return 0; }
### Prompt Develop a solution in CPP to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; const int INF = INT_MAX; const long long INFLL = (long long)1e18; const double PI = acos(-1.0); template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } const int N = (int)1e5 + 5; const int P = 1 << 18; int a, b, c; int m; int main() { ios::sync_with_stdio(false); cout.setf(ios::fixed | ios::showpoint); cout.precision(8); cin >> a >> b >> c >> m; int A = a * 2, B = b * 2, C = c; if (m <= B && m * 2 >= B) return !printf("-1\n"); if (m > C * 2) return !printf("-1\n"); if (C % 2 == 1) C = C / 2 + 1; else C /= 2; if (m * 2 < C) return !printf("-1\n"); C = -1; for (int i = c; i <= c * 2; i++) { if (m <= i && 2 * m >= i) { C = i; break; } } if (C == -1) return !printf("-1\n"); cout << A << '\n' << B << '\n' << C << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; long long power(long long a, long long b) { long long ret = 1; while (b) { if (b & 1) ret *= a; a *= a; if (ret >= MOD) ret %= MOD; if (a >= MOD) a %= MOD; b >>= 1; } return ret; } long long inv(long long x) { return power(x, MOD - 2); } const int N = 1e5 + 5; int v1, v2, v3, vm; int main() { std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> v1 >> v2 >> v3 >> vm; for (int b1 = 0; b1 <= 200; b1++) { for (int b2 = 0; b2 <= 200; b2++) { for (int b3 = 0; b3 <= 200; b3++) { if (b1 > b2 and b2 > b3 and v1 <= b1 and 2 * v1 >= b1 and v2 <= b2 and 2 * v2 >= b2 and v3 <= b3 and 2 * v3 >= b3 and (b3 >= vm and 2 * vm >= b3 and 2 * vm < b2)) { cout << b1 << "\n" << b2 << "\n" << b3; return 0; } } } } cout << "-1"; }
### Prompt Construct a Cpp code solution to the problem outlined: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; long long power(long long a, long long b) { long long ret = 1; while (b) { if (b & 1) ret *= a; a *= a; if (ret >= MOD) ret %= MOD; if (a >= MOD) a %= MOD; b >>= 1; } return ret; } long long inv(long long x) { return power(x, MOD - 2); } const int N = 1e5 + 5; int v1, v2, v3, vm; int main() { std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> v1 >> v2 >> v3 >> vm; for (int b1 = 0; b1 <= 200; b1++) { for (int b2 = 0; b2 <= 200; b2++) { for (int b3 = 0; b3 <= 200; b3++) { if (b1 > b2 and b2 > b3 and v1 <= b1 and 2 * v1 >= b1 and v2 <= b2 and 2 * v2 >= b2 and v3 <= b3 and 2 * v3 >= b3 and (b3 >= vm and 2 * vm >= b3 and 2 * vm < b2)) { cout << b1 << "\n" << b2 << "\n" << b3; return 0; } } } } cout << "-1"; } ```
#include <bits/stdc++.h> using namespace std; const int n = 3; int v[n], vm, s[n]; bool dfs(int p) { if (p == 3) return true; for (int i = v[p]; i <= 2 * v[p]; ++i) { s[p] = i; if (p) { if (2 * vm < i && i > s[p - 1]) { if (dfs(p + 1)) return true; } } else { if (vm <= i && 2 * vm >= i) { if (dfs(p + 1)) return true; } } } return false; } void solve() { if (dfs(0)) { printf("%d\n%d\n%d\n", s[2], s[1], s[0]); } else { printf("-1\n"); } } int main() { scanf("%d%d%d%d", &v[2], &v[1], &v[0], &vm); solve(); return 0; }
### Prompt Create a solution in CPP for the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int n = 3; int v[n], vm, s[n]; bool dfs(int p) { if (p == 3) return true; for (int i = v[p]; i <= 2 * v[p]; ++i) { s[p] = i; if (p) { if (2 * vm < i && i > s[p - 1]) { if (dfs(p + 1)) return true; } } else { if (vm <= i && 2 * vm >= i) { if (dfs(p + 1)) return true; } } } return false; } void solve() { if (dfs(0)) { printf("%d\n%d\n%d\n", s[2], s[1], s[0]); } else { printf("-1\n"); } } int main() { scanf("%d%d%d%d", &v[2], &v[1], &v[0], &vm); solve(); return 0; } ```
#include <bits/stdc++.h> using namespace std; template <class T> void rd(T& ret) { ret = 0; bool ok = 0, u = 0; for (;;) { int c = getchar(); if (c >= '0' && c <= '9') ret = (ret << 3) + (ret << 1) + c - '0', ok = 1; else if (c == '-') u = 1; else if (ok) { if (u) ret *= -1; return; } } } long long pow_mod(long long p, long long n, long long mod) { long long ret = 1; for (; n; n >>= 1) { if (n & 1) ret = ret * p % mod; p = p * p % mod; } return ret; } template <class T> bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template <class T> bool chmax(T& a, const T& b) { return b > a ? a = b, 1 : 0; } int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int a, b, c, d; bool climb(int a, int i) { return i >= a; } bool like(int a, int i) { return (climb(a, i) && (2 * a >= i)); } bool ok(int i, int j, int k) { if (!(climb(a, i) && like(a, i))) return 0; if (!(climb(b, j) && like(b, j))) return 0; if (!(climb(c, k) && like(c, k))) return 0; if (!(climb(d, k) && like(d, k))) return 0; if (!climb(d, i)) return 0; if (!climb(d, j)) return 0; if (!climb(d, k)) return 0; if (like(d, i)) return 0; if (like(d, j)) return 0; if (!like(d, k)) return 0; return 1; } int main() { cin >> a >> b >> c >> d; for (int i = (1); i < (210); i++) for (int j = (1); j < (i); j++) for (int k = (1); k < (j); k++) { if (ok(i, j, k)) { cout << i << " " << j << " " << k << endl; return 0; } } puts("-1"); return 0; }
### Prompt Create a solution in CPP for the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; template <class T> void rd(T& ret) { ret = 0; bool ok = 0, u = 0; for (;;) { int c = getchar(); if (c >= '0' && c <= '9') ret = (ret << 3) + (ret << 1) + c - '0', ok = 1; else if (c == '-') u = 1; else if (ok) { if (u) ret *= -1; return; } } } long long pow_mod(long long p, long long n, long long mod) { long long ret = 1; for (; n; n >>= 1) { if (n & 1) ret = ret * p % mod; p = p * p % mod; } return ret; } template <class T> bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template <class T> bool chmax(T& a, const T& b) { return b > a ? a = b, 1 : 0; } int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int a, b, c, d; bool climb(int a, int i) { return i >= a; } bool like(int a, int i) { return (climb(a, i) && (2 * a >= i)); } bool ok(int i, int j, int k) { if (!(climb(a, i) && like(a, i))) return 0; if (!(climb(b, j) && like(b, j))) return 0; if (!(climb(c, k) && like(c, k))) return 0; if (!(climb(d, k) && like(d, k))) return 0; if (!climb(d, i)) return 0; if (!climb(d, j)) return 0; if (!climb(d, k)) return 0; if (like(d, i)) return 0; if (like(d, j)) return 0; if (!like(d, k)) return 0; return 1; } int main() { cin >> a >> b >> c >> d; for (int i = (1); i < (210); i++) for (int j = (1); j < (i); j++) for (int k = (1); k < (j); k++) { if (ok(i, j, k)) { cout << i << " " << j << " " << k << endl; return 0; } } puts("-1"); return 0; } ```
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:5000000000") const unsigned long long mod = 1000000007; long long Inf = (long long)2e9; long long LINF = (long long)1e18 + 1e17; using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; for (int i = a; i <= 2 * a; i++) { for (int j = b; j <= 2 * b; j++) { if (j < i) { int x_max = min(j - 1, 2 * c), x_min = c; if (2 * d < x_min || d > x_max) continue; if (2 * d >= j) continue; for (int k = x_min; k <= x_max; k++) { if (2 * d >= k && k >= d && 2 * k < j) { cout << i << " " << j << " " << k; return 0; } } } } } puts("-1"); return 0; }
### Prompt Develop a solution in cpp to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> #pragma comment(linker, "/STACK:5000000000") const unsigned long long mod = 1000000007; long long Inf = (long long)2e9; long long LINF = (long long)1e18 + 1e17; using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; for (int i = a; i <= 2 * a; i++) { for (int j = b; j <= 2 * b; j++) { if (j < i) { int x_max = min(j - 1, 2 * c), x_min = c; if (2 * d < x_min || d > x_max) continue; if (2 * d >= j) continue; for (int k = x_min; k <= x_max; k++) { if (2 * d >= k && k >= d && 2 * k < j) { cout << i << " " << j << " " << k; return 0; } } } } } puts("-1"); return 0; } ```
#include <bits/stdc++.h> using namespace std; int const N = 5005; int mod = 1000000007; int main() { int v1, v2, v3, vm; cin >> v3 >> v2 >> v1 >> vm; if ((v1 > 2 * vm or vm > 2 * v1) or 2 * v3 <= 2 * vm or 2 * v2 <= 2 * vm) cout << -1 << endl; else { cout << v3 * 2 << endl; cout << v2 * 2 << endl; cout << max(vm, v1) << endl; } return 0; }
### Prompt Please formulate a cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int const N = 5005; int mod = 1000000007; int main() { int v1, v2, v3, vm; cin >> v3 >> v2 >> v1 >> vm; if ((v1 > 2 * vm or vm > 2 * v1) or 2 * v3 <= 2 * vm or 2 * v2 <= 2 * vm) cout << -1 << endl; else { cout << v3 * 2 << endl; cout << v2 * 2 << endl; cout << max(vm, v1) << endl; } return 0; } ```
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int f, m, s, ma; int main() { scanf("%d %d %d %d", &f, &m, &s, &ma); int fm, fmi, mm, sm, smi, mam, mmi; fm = 2 * f; mm = 2 * m; sm = 2 * s; mam = m * 2; if (ma > fm || ma > mm || ma > sm || 2 * s < ma || 2 * ma < s || (2 * m <= 2 * ma)) { printf("-1"); return 0; } int fc, mc, sc; fc = 2 * f; mc = 2 * m; if (ma <= s) sc = s; else sc = ma; if (sc >= mc) { printf("-1"); return 0; } printf("%d\n%d\n%d", fc, mc, sc); return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int f, m, s, ma; int main() { scanf("%d %d %d %d", &f, &m, &s, &ma); int fm, fmi, mm, sm, smi, mam, mmi; fm = 2 * f; mm = 2 * m; sm = 2 * s; mam = m * 2; if (ma > fm || ma > mm || ma > sm || 2 * s < ma || 2 * ma < s || (2 * m <= 2 * ma)) { printf("-1"); return 0; } int fc, mc, sc; fc = 2 * f; mc = 2 * m; if (ma <= s) sc = s; else sc = ma; if (sc >= mc) { printf("-1"); return 0; } printf("%d\n%d\n%d", fc, mc, sc); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; if (2 * v3 < v4 || 2 * v4 < v3 || v4 >= v2) { cout << "-1"; } else { cout << 2 * v1 << endl << 2 * v2 << endl << max(v3, v4); } return 0; }
### Prompt In cpp, your task is to solve the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; if (2 * v3 < v4 || 2 * v4 < v3 || v4 >= v2) { cout << "-1"; } else { cout << 2 * v1 << endl << 2 * v2 << endl << max(v3, v4); } return 0; } ```
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 1; vector<int> v[N]; int vis[N]; long long int cnt1 = 0, cnt2 = 0, cnt = 0, m, n, x, y, z, i, j, k, mini, d, a, b, c, o; int color[N] = {0}; long long int brr[N]; void dfs(int s, int t) { vis[s] = 1; color[s] = t; for (int i = 0; i < v[s].size(); i++) { if (!vis[v[s][i]]) dfs(v[s][i], t); } } int main() { cin >> a >> b >> c >> d; for (int i = a; i <= 2 * a; i++) { for (int j = b; j <= 2 * b; j++) { for (int k = c; k <= 2 * c; k++) { if (i > j && j > k && k >= d && 2 * d >= k && 2 * d < j) { cout << i << endl << j << endl << k << endl; return 0; } } } } cout << -1; return 0; }
### Prompt Your task is to create a cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int N = 1e4 + 1; vector<int> v[N]; int vis[N]; long long int cnt1 = 0, cnt2 = 0, cnt = 0, m, n, x, y, z, i, j, k, mini, d, a, b, c, o; int color[N] = {0}; long long int brr[N]; void dfs(int s, int t) { vis[s] = 1; color[s] = t; for (int i = 0; i < v[s].size(); i++) { if (!vis[v[s][i]]) dfs(v[s][i], t); } } int main() { cin >> a >> b >> c >> d; for (int i = a; i <= 2 * a; i++) { for (int j = b; j <= 2 * b; j++) { for (int k = c; k <= 2 * c; k++) { if (i > j && j > k && k >= d && 2 * d >= k && 2 * d < j) { cout << i << endl << j << endl << k << endl; return 0; } } } } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int f, m, s, mas; cin >> f >> m >> s >> mas; if (mas > 2 * s || s > 2 * mas) { cout << -1; return 0; } int sc = s; while (sc < mas) ++sc; if (sc >= m) { cout << -1; return 0; } cout << 2 * f << endl << 2 * m << endl; cout << sc << endl; return 0; }
### Prompt Create a solution in cpp for the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int f, m, s, mas; cin >> f >> m >> s >> mas; if (mas > 2 * s || s > 2 * mas) { cout << -1; return 0; } int sc = s; while (sc < mas) ++sc; if (sc >= m) { cout << -1; return 0; } cout << 2 * f << endl << 2 * m << endl; cout << sc << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int Father, Mother, Son, Masha, sizeMasha; int ans1, ans2, ans3; int main() { cin >> Father >> Mother >> Son >> Masha; for (int sizeFather = Father; sizeFather <= 2 * Father; sizeFather++) { for (int sizeMother = Mother; sizeMother <= 2 * Mother; sizeMother++) { for (int sizeSon = Son; sizeSon <= 2 * Son; sizeSon++) { sizeMasha = 2 * Masha; if (sizeFather > sizeMother && sizeMother > sizeSon) { if (sizeMasha >= sizeSon && sizeMasha < sizeMother && sizeMasha < sizeFather) { if (Masha <= sizeSon && Masha <= sizeMother && Masha <= sizeFather) { ans1 = sizeFather, ans2 = sizeMother, ans3 = sizeSon; cout << ans1 << "\n" << ans2 << "\n" << ans3 << "\n"; return 0; } } } } } } cout << "-1\n"; return 0; }
### Prompt Please formulate a CPP solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int Father, Mother, Son, Masha, sizeMasha; int ans1, ans2, ans3; int main() { cin >> Father >> Mother >> Son >> Masha; for (int sizeFather = Father; sizeFather <= 2 * Father; sizeFather++) { for (int sizeMother = Mother; sizeMother <= 2 * Mother; sizeMother++) { for (int sizeSon = Son; sizeSon <= 2 * Son; sizeSon++) { sizeMasha = 2 * Masha; if (sizeFather > sizeMother && sizeMother > sizeSon) { if (sizeMasha >= sizeSon && sizeMasha < sizeMother && sizeMasha < sizeFather) { if (Masha <= sizeSon && Masha <= sizeMother && Masha <= sizeFather) { ans1 = sizeFather, ans2 = sizeMother, ans3 = sizeSon; cout << ans1 << "\n" << ans2 << "\n" << ans3 << "\n"; return 0; } } } } } } cout << "-1\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int v1, v2, v3, vm; int main() { cin >> v1 >> v2 >> v3 >> vm; if (vm > v3 * 2 || vm >= v2 || vm * 2 < v3) { cout << -1; return 0; } else { cout << v1 * 2 << " " << v2 * 2 << " " << max(v3, vm); } return 0; }
### Prompt Please create a solution in cpp to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int v1, v2, v3, vm; int main() { cin >> v1 >> v2 >> v3 >> vm; if (vm > v3 * 2 || vm >= v2 || vm * 2 < v3) { cout << -1; return 0; } else { cout << v1 * 2 << " " << v2 * 2 << " " << max(v3, vm); } return 0; } ```
#include <bits/stdc++.h> using namespace std; int a, b, c, d; int ansa, ansb, ansc; int read() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return x * f; } int main() { a = read(); b = read(); c = read(); d = read(); if (c * 2 < d || d * 2 < c || a <= d || b <= d) { printf("-1"); return 0; } printf("%d\n%d\n%d", a * 2, b * 2, min(c * 2, d * 2)); return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int a, b, c, d; int ansa, ansb, ansc; int read() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return x * f; } int main() { a = read(); b = read(); c = read(); d = read(); if (c * 2 < d || d * 2 < c || a <= d || b <= d) { printf("-1"); return 0; } printf("%d\n%d\n%d", a * 2, b * 2, min(c * 2, d * 2)); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v; cin >> v1 >> v2 >> v3 >> v; int second = -1, m = -1, l = -1; for (int i = v; i <= 230; i++) { for (int j = i + 1; j <= 230; j++) { for (int k = j + 1; k <= 230; k++) { if (2 * v < j && 2 * v < k && 2 * v >= i && 2 * v3 >= i && i >= v3 && 2 * v2 >= j && 2 * v1 >= k && j >= v2 && k >= v1) { second = i; m = j; l = k; break; } } if (second != -1) break; } if (second != -1) break; } if (second == -1) cout << -1; else { cout << l << "\n"; cout << m << "\n"; cout << second << "\n"; } }
### Prompt Please formulate a Cpp solution to the following problem: A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≀ b, he or she likes it if and only if he can climb into this car and 2a β‰₯ b. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. Input You are given four integers V1, V2, V3, Vm(1 ≀ Vi ≀ 100) β€” sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3. Output Output three integers β€” sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes). Examples Input 50 30 10 10 Output 50 30 10 Input 100 50 10 21 Output -1 Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v; cin >> v1 >> v2 >> v3 >> v; int second = -1, m = -1, l = -1; for (int i = v; i <= 230; i++) { for (int j = i + 1; j <= 230; j++) { for (int k = j + 1; k <= 230; k++) { if (2 * v < j && 2 * v < k && 2 * v >= i && 2 * v3 >= i && i >= v3 && 2 * v2 >= j && 2 * v1 >= k && j >= v2 && k >= v1) { second = i; m = j; l = k; break; } } if (second != -1) break; } if (second != -1) break; } if (second == -1) cout << -1; else { cout << l << "\n"; cout << m << "\n"; cout << second << "\n"; } } ```