output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> using namespace std; int v1, v2, v3, vm; int vm1, vm2, vm3; int main() { cin >> v1 >> v2 >> v3 >> vm; vm1 = 2 * v1; vm2 = 2 * v2; vm3 = max(v3, vm); if (vm3 > 2 * min(v3, vm)) { cout << "-1"; return 0; } if (vm1 <= 2 * vm || vm2 <= 2 * vm) { cout << "-1"; return 0; } cout << vm1 << '\n' << vm2 << '\n' << vm3; }
### 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 vm1, vm2, vm3; int main() { cin >> v1 >> v2 >> v3 >> vm; vm1 = 2 * v1; vm2 = 2 * v2; vm3 = max(v3, vm); if (vm3 > 2 * min(v3, vm)) { cout << "-1"; return 0; } if (vm1 <= 2 * vm || vm2 <= 2 * vm) { cout << "-1"; return 0; } cout << vm1 << '\n' << vm2 << '\n' << vm3; } ```
#include <bits/stdc++.h> using namespace std; int v1, v2, v3, v4; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> v1 >> v2 >> v3 >> v4; for (int i = v1; i <= v1 * 2; ++i) { for (int j = v2; j <= 2 * v2 && j < i; ++j) { for (int ii = v3; ii <= 2 * v3 && ii < j; ++ii) { if (v4 <= ii && v4 * 2 >= ii && v4 * 2 < j && v4 * 2 < i && v4 <= i && v4 <= j) { cout << i << endl << j << endl << ii; 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; int v1, v2, v3, v4; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> v1 >> v2 >> v3 >> v4; for (int i = v1; i <= v1 * 2; ++i) { for (int j = v2; j <= 2 * v2 && j < i; ++j) { for (int ii = v3; ii <= 2 * v3 && ii < j; ++ii) { if (v4 <= ii && v4 * 2 >= ii && v4 * 2 < j && v4 * 2 < i && v4 <= i && v4 <= j) { cout << i << endl << j << endl << ii; return 0; } } } } cout << -1; } ```
#include <bits/stdc++.h> using namespace std; int v, v1, v2, v3, ans1, ans2, ans3; int main() { scanf("%d%d%d%d", &v1, &v2, &v3, &v); ans1 = 2 * v1; ans2 = 2 * v2; if (v3 >= v) { if (v3 <= 2 * v) { ans3 = v3; if (v * 2 >= ans2) printf("-1"); else printf("%d\n%d\n%d\n", ans1, ans2, ans3); } else printf("-1"); } else { if (v <= 2 * v3) { ans3 = v; if (v * 2 >= ans2) printf("-1"); else printf("%d\n%d\n%d\n", ans1, ans2, ans3); } else printf("-1"); } }
### 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, v1, v2, v3, ans1, ans2, ans3; int main() { scanf("%d%d%d%d", &v1, &v2, &v3, &v); ans1 = 2 * v1; ans2 = 2 * v2; if (v3 >= v) { if (v3 <= 2 * v) { ans3 = v3; if (v * 2 >= ans2) printf("-1"); else printf("%d\n%d\n%d\n", ans1, ans2, ans3); } else printf("-1"); } else { if (v <= 2 * v3) { ans3 = v; if (v * 2 >= ans2) printf("-1"); else printf("%d\n%d\n%d\n", ans1, ans2, ans3); } else printf("-1"); } } ```
#include <bits/stdc++.h> using namespace std; const long double PI = 3.141592653589793238462643383; struct Rcompare { bool operator()(pair<int, int> lhs, pair<int, int> rhs) { return lhs.first > rhs.first; } }; struct compare { bool operator()(pair<int, int> lhs, pair<int, int> rhs) { return lhs.first < rhs.first; } }; long long int gcd(long long int a, long long int b) { if (a == 0) return b; return gcd(b % a, a); } long long int lcm(long long int a, long long int b) { return a * (b / gcd(a, b)); } long long int Abs(long long int a) { if (a > 0) return a; return -a; } long long int Ceil(long long int a, long long int b) { if (a % b == 0) return a / b; else return a / b + 1; } double Abs(double a) { if (a > 0) return a; return -a; } long long int pow(long long int x, long long int y) { if (y == 0) return 1; long long int tmp = pow(x, y / 2); if (y % 2 == 1) return ((tmp * tmp) * x); return (tmp * tmp); } const int MAX = 100009; const int MOD = 1e9 + 7; const int inf = 1e9 + 10; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int a, b, c, m; cin >> c >> b >> a >> m; if (2 * a < m || a > 2 * m) { cout << -1 << '\n'; return 0; } else if (2 * m > 2 * b || 2 * m > 2 * c) { cout << -1 << '\n'; return 0; } else { for (int i = max(2 * m + 1, c); i <= (2 * c); ++i) for (int j = max(2 * m + 1, b); j <= (2 * b); ++j) for (int k = max(a, m); k <= (min(2 * a, 2 * m)); ++k) { if (k < j && j < i) { cout << i << '\n' << j << '\n' << k << '\n'; return 0; } } } 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 double PI = 3.141592653589793238462643383; struct Rcompare { bool operator()(pair<int, int> lhs, pair<int, int> rhs) { return lhs.first > rhs.first; } }; struct compare { bool operator()(pair<int, int> lhs, pair<int, int> rhs) { return lhs.first < rhs.first; } }; long long int gcd(long long int a, long long int b) { if (a == 0) return b; return gcd(b % a, a); } long long int lcm(long long int a, long long int b) { return a * (b / gcd(a, b)); } long long int Abs(long long int a) { if (a > 0) return a; return -a; } long long int Ceil(long long int a, long long int b) { if (a % b == 0) return a / b; else return a / b + 1; } double Abs(double a) { if (a > 0) return a; return -a; } long long int pow(long long int x, long long int y) { if (y == 0) return 1; long long int tmp = pow(x, y / 2); if (y % 2 == 1) return ((tmp * tmp) * x); return (tmp * tmp); } const int MAX = 100009; const int MOD = 1e9 + 7; const int inf = 1e9 + 10; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int a, b, c, m; cin >> c >> b >> a >> m; if (2 * a < m || a > 2 * m) { cout << -1 << '\n'; return 0; } else if (2 * m > 2 * b || 2 * m > 2 * c) { cout << -1 << '\n'; return 0; } else { for (int i = max(2 * m + 1, c); i <= (2 * c); ++i) for (int j = max(2 * m + 1, b); j <= (2 * b); ++j) for (int k = max(a, m); k <= (min(2 * a, 2 * m)); ++k) { if (k < j && j < i) { cout << i << '\n' << j << '\n' << k << '\n'; return 0; } } } cout << -1 << '\n'; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if ((a > b && a > c) && (b < a || b > c) && (c < a && c < b)) { if (d > 2 * c || d >= b || c > 2 * d) cout << -1; else { cout << 2 * a << endl; cout << 2 * b << endl; cout << max(c, d); } } 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; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if ((a > b && a > c) && (b < a || b > c) && (c < a && c < b)) { if (d > 2 * c || d >= b || c > 2 * d) cout << -1; else { cout << 2 * a << endl; cout << 2 * b << endl; cout << max(c, d); } } else cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; using ll = long long; bool like(int a, int b) { return a <= b && 2 * a >= b; } int main() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; v1 *= 2; v2 *= 2; v3 = max(v3, 2 * min(v3, vm)); if (!like(vm, v1) && !like(vm, v2) && like(vm, v3)) { printf("%d\n%d\n%d\n", v1, v2, v3); } else printf("-1\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; using ll = long long; bool like(int a, int b) { return a <= b && 2 * a >= b; } int main() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; v1 *= 2; v2 *= 2; v3 = max(v3, 2 * min(v3, vm)); if (!like(vm, v1) && !like(vm, v2) && like(vm, v3)) { printf("%d\n%d\n%d\n", v1, v2, v3); } else printf("-1\n"); } ```
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; const long long mod = 1e9 + 7; int l, m, s, ms; int32_t main() { ios_base ::sync_with_stdio(0); cin.tie(); cout.tie(); cin >> l >> m >> s >> ms; if (m <= ms || s > 2 * ms || ms > 2 * s || max(m, 2 * ms + 1) > 2 * l) return cout << -1 << endl, 0; cout << 2 * l << '\n' << max(m, 2 * ms + 1) << '\n' << max(s, ms); }
### 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("O3") using namespace std; const long long mod = 1e9 + 7; int l, m, s, ms; int32_t main() { ios_base ::sync_with_stdio(0); cin.tie(); cout.tie(); cin >> l >> m >> s >> ms; if (m <= ms || s > 2 * ms || ms > 2 * s || max(m, 2 * ms + 1) > 2 * l) return cout << -1 << endl, 0; cout << 2 * l << '\n' << max(m, 2 * ms + 1) << '\n' << max(s, ms); } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; scanf("%d", &v1) == 0, scanf("%d", &v2) == 0, scanf("%d", &v3) == 0, scanf("%d", &vm) == 0; int rv1 = v1 * 2; int rv2 = v2 * 2; int rv3 = max(v3, vm); if (rv2 > rv3 * 2 && v3 * 2 >= rv3 && vm * 2 >= rv3) { printf("%d\n", rv1), printf("%d\n", rv2), printf("%d\n", rv3); } else { printf("%d\n", -1); } }
### 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; scanf("%d", &v1) == 0, scanf("%d", &v2) == 0, scanf("%d", &v3) == 0, scanf("%d", &vm) == 0; int rv1 = v1 * 2; int rv2 = v2 * 2; int rv3 = max(v3, vm); if (rv2 > rv3 * 2 && v3 * 2 >= rv3 && vm * 2 >= rv3) { printf("%d\n", rv1), printf("%d\n", rv2), printf("%d\n", rv3); } else { printf("%d\n", -1); } } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, flag = 0; scanf("%d%d", &a, &b); scanf("%d%d", &c, &d); for (int i = 1; i < 201; i += 1) for (int j = 1; j < i; j += 1) for (int k = 1; k < j; k += 1) { if (a <= i && b <= j && c <= k && d <= i && d <= j && d <= k && 2 * d >= k && 2 * d < j && 2 * a >= i && 2 * b >= j && 2 * c >= k) { printf("%d\n%d\n%d\n", i, j, k); return 0; } } printf("-1\n"); }
### 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, flag = 0; scanf("%d%d", &a, &b); scanf("%d%d", &c, &d); for (int i = 1; i < 201; i += 1) for (int j = 1; j < i; j += 1) for (int k = 1; k < j; k += 1) { if (a <= i && b <= j && c <= k && d <= i && d <= j && d <= k && 2 * d >= k && 2 * d < j && 2 * a >= i && 2 * b >= j && 2 * c >= k) { printf("%d\n%d\n%d\n", i, j, k); return 0; } } printf("-1\n"); } ```
#include <bits/stdc++.h> using namespace std; int main() { vector<int> ans; int v1, v2, v3, vm; bool d1 = false, d2 = false, d3 = false; cin >> v1 >> v2 >> v3 >> vm; if (v1 <= 0 || v2 <= 0 || v3 <= 0 || vm <= 0) { cout << "-1" << endl; return 0; } int y = (2 * v1) + 1; int x = min(v3, vm); for (int i = y; i > 0; i--) { if (!d1 && v1 <= i && 2 * v1 >= i && vm <= i && 2 * vm < i) { d1 = true; ans.push_back(i); } else if (!d2 && v2 <= i && 2 * v2 >= i && vm <= i && 2 * vm < i) { d2 = true; ans.push_back(i); } else if (!d3 && v3 <= i && 2 * v3 >= i && vm <= i && 2 * vm >= i) { d3 = true; ans.push_back(i); } if (d1 == true && d2 == true && d3 == true) { break; } else if (d1 == false && d2 == true && d3 == true) { break; } } if (d1 == true && d2 == true && d3 == true && ans.size() == 3) { for (int i = 0; i < ans.size(); i++) { cout << ans[i] << endl; } } else { 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 main() { vector<int> ans; int v1, v2, v3, vm; bool d1 = false, d2 = false, d3 = false; cin >> v1 >> v2 >> v3 >> vm; if (v1 <= 0 || v2 <= 0 || v3 <= 0 || vm <= 0) { cout << "-1" << endl; return 0; } int y = (2 * v1) + 1; int x = min(v3, vm); for (int i = y; i > 0; i--) { if (!d1 && v1 <= i && 2 * v1 >= i && vm <= i && 2 * vm < i) { d1 = true; ans.push_back(i); } else if (!d2 && v2 <= i && 2 * v2 >= i && vm <= i && 2 * vm < i) { d2 = true; ans.push_back(i); } else if (!d3 && v3 <= i && 2 * v3 >= i && vm <= i && 2 * vm >= i) { d3 = true; ans.push_back(i); } if (d1 == true && d2 == true && d3 == true) { break; } else if (d1 == false && d2 == true && d3 == true) { break; } } if (d1 == true && d2 == true && d3 == true && ans.size() == 3) { for (int i = 0; i < ans.size(); i++) { cout << ans[i] << endl; } } else { cout << "-1" << endl; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n, i, a, b, c, m, k, j; cin >> a >> b >> c >> m; bool flag = 0; for (i = a; i < 2 * a + 1; i++) { for (j = b; j < 2 * b + 1; j++) { for (k = c; k < 2 * c + 1; k++) { if (i > j and j > k and i > k and m <= i and m <= j and m <= k and 2 * m >= k and 2 * m < j and 2 * m < i) { flag = 1; break; } } if (flag) break; } if (flag) break; } if (flag) cout << i << "\n" << j << endl << k; else cout << "-1"; 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 n, i, a, b, c, m, k, j; cin >> a >> b >> c >> m; bool flag = 0; for (i = a; i < 2 * a + 1; i++) { for (j = b; j < 2 * b + 1; j++) { for (k = c; k < 2 * c + 1; k++) { if (i > j and j > k and i > k and m <= i and m <= j and m <= k and 2 * m >= k and 2 * m < j and 2 * m < i) { flag = 1; break; } } if (flag) break; } if (flag) break; } if (flag) cout << i << "\n" << j << endl << k; else cout << "-1"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int a, b, c, m; bool e = true; int main() { cin >> a >> b >> c >> m; if (m >= a) e = false; if (m >= b) e = false; if (m > c) { if (m > 2 * c) e = false; else c = m; } if (m < c) { if (c > 2 * m) e = false; } if (e == true) { cout << 2 * a << endl << 2 * b << endl << c; } if (e == false) cout << "-1"; 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, m; bool e = true; int main() { cin >> a >> b >> c >> m; if (m >= a) e = false; if (m >= b) e = false; if (m > c) { if (m > 2 * c) e = false; else c = m; } if (m < c) { if (c > 2 * m) e = false; } if (e == true) { cout << 2 * a << endl << 2 * b << endl << c; } if (e == false) cout << "-1"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { long long i, j, k = 1, l, n, t, a, b, c, d; cin >> a >> b >> c >> d; if (d > c * 2 || c > d * 2 || d >= b) cout << -1 << endl; else cout << a * 2 << endl << b * 2 << endl << max(c, d) << endl; }
### 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 argc, char const *argv[]) { long long i, j, k = 1, l, n, t, a, b, c, d; cin >> a >> b >> c >> d; if (d > c * 2 || c > d * 2 || d >= b) cout << -1 << endl; else cout << a * 2 << endl << b * 2 << endl << max(c, d) << endl; } ```
#include <bits/stdc++.h> template <class _T> bool maximize(_T &a, _T b) { return a < b ? a = b, 1 : 0; } template <class _T> bool minimize(_T &a, _T b) { return a > b ? a = b, 1 : 0; } const int ooit = 2e9; const long long ooll = 1e15; using namespace std; int v1, v2, v3, vm; void enter() { cin >> v1 >> v2 >> v3 >> vm; } bool check() { if (max(v1, vm) > 2 * v1) return false; if (max(v2, vm) > 2 * v2) return false; if (max(vm, v3) > min(2 * vm, 2 * v3)) return false; return true; } void process() { if (!check()) cout << -1; else { int car1 = 2 * v1, car2 = -1, car3 = -1; for (int i = car1 - 1; i >= max(vm, v2); i--) if (i >= max(vm, v2) && i <= 2 * v2) { car2 = i; break; } if (car2 == -1) { cout << -1; return; } for (int i = car2 - 1; i >= max(vm, v3); i--) if (i >= max(vm, v3) && i <= min(2 * vm, 2 * v3)) { car3 = i; break; } if (car3 == -1) { cout << -1; return; } if (2 * vm >= car1) { cout << -1; return; } if (2 * vm >= car2) { cout << -1; return; } cout << car1 << endl << car2 << endl << car3; } } int main() { enter(); process(); 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> template <class _T> bool maximize(_T &a, _T b) { return a < b ? a = b, 1 : 0; } template <class _T> bool minimize(_T &a, _T b) { return a > b ? a = b, 1 : 0; } const int ooit = 2e9; const long long ooll = 1e15; using namespace std; int v1, v2, v3, vm; void enter() { cin >> v1 >> v2 >> v3 >> vm; } bool check() { if (max(v1, vm) > 2 * v1) return false; if (max(v2, vm) > 2 * v2) return false; if (max(vm, v3) > min(2 * vm, 2 * v3)) return false; return true; } void process() { if (!check()) cout << -1; else { int car1 = 2 * v1, car2 = -1, car3 = -1; for (int i = car1 - 1; i >= max(vm, v2); i--) if (i >= max(vm, v2) && i <= 2 * v2) { car2 = i; break; } if (car2 == -1) { cout << -1; return; } for (int i = car2 - 1; i >= max(vm, v3); i--) if (i >= max(vm, v3) && i <= min(2 * vm, 2 * v3)) { car3 = i; break; } if (car3 == -1) { cout << -1; return; } if (2 * vm >= car1) { cout << -1; return; } if (2 * vm >= car2) { cout << -1; return; } cout << car1 << endl << car2 << endl << car3; } } int main() { enter(); process(); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, aa, bb, cc; cin >> a >> b >> c >> d; cc = max(c, d); bb = b > cc ? b : cc + 1; bb = bb <= 2 * d ? 2 * d + 1 : bb; aa = a > bb ? a : bb + 1; if (aa >= a && aa <= 2 * a && bb >= b && bb <= 2 * b && cc >= c && cc <= 2 * c && cc >= d && cc <= 2 * d) { cout << aa << endl; cout << bb << endl; cout << cc << endl; } else { cout << "-1"; } 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 a, b, c, d, aa, bb, cc; cin >> a >> b >> c >> d; cc = max(c, d); bb = b > cc ? b : cc + 1; bb = bb <= 2 * d ? 2 * d + 1 : bb; aa = a > bb ? a : bb + 1; if (aa >= a && aa <= 2 * a && bb >= b && bb <= 2 * b && cc >= c && cc <= 2 * c && cc >= d && cc <= 2 * d) { cout << aa << endl; cout << bb << endl; cout << cc << endl; } else { cout << "-1"; } return 0; } ```
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fll; const long double pi = acos(-1); const int MOD = 1e9 + 7; int v[330]; int main() { int a, b, c, m; cin >> a >> b >> c >> m; for (int i = a; i <= 2 * a; i++) { v[i] |= 1; } for (int i = b; i <= 2 * b; i++) { v[i] |= 2; } for (int i = c; i <= 2 * c; i++) { v[i] |= 4; } for (int i = m; i <= 2 * m; i++) { v[i] |= 8; } int x = -1, y = -1, z = -1; for (int i = 300; i >= 0; i--) { if (v[i] & 1 and x == -1) x = i; else if (v[i] & 2 and x != -1 and y == -1) y = i; else if (v[i] == 12 and z == -1 and x != -1 and y != -1) z = i; } cerr << "x" << " == " << x << endl; ; cerr << "y" << " == " << y << endl; ; cerr << "z" << " == " << z << endl; ; if (x == -1 or y == -1 or z == -1) { printf("%d\n", -1); } else { printf("%d\n", x); printf("%d\n", y); printf("%d\n", z); } 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 LINF = 0x3f3f3f3f3f3f3f3fll; const long double pi = acos(-1); const int MOD = 1e9 + 7; int v[330]; int main() { int a, b, c, m; cin >> a >> b >> c >> m; for (int i = a; i <= 2 * a; i++) { v[i] |= 1; } for (int i = b; i <= 2 * b; i++) { v[i] |= 2; } for (int i = c; i <= 2 * c; i++) { v[i] |= 4; } for (int i = m; i <= 2 * m; i++) { v[i] |= 8; } int x = -1, y = -1, z = -1; for (int i = 300; i >= 0; i--) { if (v[i] & 1 and x == -1) x = i; else if (v[i] & 2 and x != -1 and y == -1) y = i; else if (v[i] == 12 and z == -1 and x != -1 and y != -1) z = i; } cerr << "x" << " == " << x << endl; ; cerr << "y" << " == " << y << endl; ; cerr << "z" << " == " << z << endl; ; if (x == -1 or y == -1 or z == -1) { printf("%d\n", -1); } else { printf("%d\n", x); printf("%d\n", y); printf("%d\n", z); } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (2 * c < d || 2 * d < c || d >= b) cout << "-1"; else { cout << 2 * a << endl << 2 * b << endl; if (c > d) cout << c; else cout << d; } 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 (2 * c < d || 2 * d < c || d >= b) cout << "-1"; else { cout << 2 * a << endl << 2 * b << endl; if (c > d) cout << c; else cout << d; } return 0; } ```
#include <bits/stdc++.h> int main() { int father, mother, son, masha; scanf("%d %d %d %d", &father, &mother, &son, &masha); if (masha > son * 2 || son > masha * 2 || masha >= mother) { printf("-1\n"); } else { father *= 2; mother *= 2; printf("%d %d ", father, mother); if (son > masha) { printf("%d", son); } else { printf("%d", masha); } } 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> int main() { int father, mother, son, masha; scanf("%d %d %d %d", &father, &mother, &son, &masha); if (masha > son * 2 || son > masha * 2 || masha >= mother) { printf("-1\n"); } else { father *= 2; mother *= 2; printf("%d %d ", father, mother); if (son > masha) { printf("%d", son); } else { printf("%d", masha); } } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (int i = 200; i > 0; i--) { for (int j = i - 1; j > 0; j--) { for (int k = j - 1; k > 0; k--) { if ((v1 <= i and 2 * v1 >= i) and (v2 <= j and 2 * v2 >= j) and (v3 <= k and 2 * v3 >= k) and (vm <= i and vm <= j and vm <= k and 2 * vm >= k and 2 * vm < j and 2 * vm < i)) { cout << i << endl << j << endl << k << endl; return 0; } } } } 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; int main() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (int i = 200; i > 0; i--) { for (int j = i - 1; j > 0; j--) { for (int k = j - 1; k > 0; k--) { if ((v1 <= i and 2 * v1 >= i) and (v2 <= j and 2 * v2 >= j) and (v3 <= k and 2 * v3 >= k) and (vm <= i and vm <= j and vm <= k and 2 * vm >= k and 2 * vm < j and 2 * vm < i)) { cout << i << endl << j << endl << k << endl; return 0; } } } } cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int e, f, g; if (d > 2 * c || 2 * d < c) { cout << -1 << endl; return 0; } g = max(d, c); f = max(b, 2 * d + 1); if (f > 2 * b) { cout << -1 << endl; return 0; } e = max(a, f + 1); if (e > 2 * a) { cout << -1 << endl; return 0; } cout << e << endl; cout << f << endl; cout << g << 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; int e, f, g; if (d > 2 * c || 2 * d < c) { cout << -1 << endl; return 0; } g = max(d, c); f = max(b, 2 * d + 1); if (f > 2 * b) { cout << -1 << endl; return 0; } e = max(a, f + 1); if (e > 2 * a) { cout << -1 << endl; return 0; } cout << e << endl; cout << f << endl; cout << g << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; const long long MX = 1e10; const int INF = 1e9 + 7; const double EPS = 0.00000001; int main() { ios_base::sync_with_stdio(false); int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (int i = 1; i <= 205; i++) { for (int j = i + 1; j <= 205; j++) { for (int k = j + 1; k <= 205; k++) { if (i >= v3 && j >= v2 && k >= v1) { if (i <= 2 * v3 && j <= 2 * v2 && k <= 2 * v1) { if (i >= vm && j >= vm && k >= vm) { if (i <= 2 * vm && j > 2 * vm && k > 2 * vm) { cout << k << endl; cout << j << endl; cout << i << 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; const long long MX = 1e10; const int INF = 1e9 + 7; const double EPS = 0.00000001; int main() { ios_base::sync_with_stdio(false); int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (int i = 1; i <= 205; i++) { for (int j = i + 1; j <= 205; j++) { for (int k = j + 1; k <= 205; k++) { if (i >= v3 && j >= v2 && k >= v1) { if (i <= 2 * v3 && j <= 2 * v2 && k <= 2 * v1) { if (i >= vm && j >= vm && k >= vm) { if (i <= 2 * vm && j > 2 * vm && k > 2 * vm) { cout << k << endl; cout << j << endl; cout << i << endl; return 0; } } } } } } } cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v4, ans1, ans2, ans3, flag = 0, i, j, k; cin >> v1 >> v2 >> v3 >> v4; for (i = v1; i <= 2 * v1; i++) { for (j = v2; j < i && j <= 2 * v2; j++) { for (k = v3; k < j && k <= 2 * v3; k++) { if (k <= 2 * v4 && v4 <= k && 2 * v4 < j && 2 * v4 < i) { flag = 1; break; } } if (flag) break; } if (flag) break; } if (flag) { cout << i << "\n" << j << "\n" << k << "\n"; } else { cout << "-1\n"; } }
### 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, ans1, ans2, ans3, flag = 0, i, j, k; cin >> v1 >> v2 >> v3 >> v4; for (i = v1; i <= 2 * v1; i++) { for (j = v2; j < i && j <= 2 * v2; j++) { for (k = v3; k < j && k <= 2 * v3; k++) { if (k <= 2 * v4 && v4 <= k && 2 * v4 < j && 2 * v4 < i) { flag = 1; break; } } if (flag) break; } if (flag) break; } if (flag) { cout << i << "\n" << j << "\n" << k << "\n"; } else { cout << "-1\n"; } } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int e = max(c, d); if (e > 2 * c || e > 2 * d || e >= b) { cout << -1; return 0; } cout << 2 * a << endl << 2 * b << endl << e; 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; cin >> a >> b >> c >> d; int e = max(c, d); if (e > 2 * c || e > 2 * d || e >= b) { cout << -1; return 0; } cout << 2 * a << endl << 2 * b << endl << e; return 0; } ```
#include <bits/stdc++.h> using namespace std; int a, b, c, x; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> a >> b >> c >> x; for (int i = a; i <= 2 * a; i++) for (int j = b; j <= min(i - 1, 2 * b); j++) for (int k = c; k <= min(j - 1, 2 * c); k++) if (a <= i && b <= j && c <= k && 2 * a >= i && 2 * b >= j && 2 * c >= k && x <= i && x <= j && x <= k && 2 * x < i && 2 * x < j && 2 * x >= k) return cout << i << endl << j << endl << k << endl, 0; ; 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; int a, b, c, x; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> a >> b >> c >> x; for (int i = a; i <= 2 * a; i++) for (int j = b; j <= min(i - 1, 2 * b); j++) for (int k = c; k <= min(j - 1, 2 * c); k++) if (a <= i && b <= j && c <= k && 2 * a >= i && 2 * b >= j && 2 * c >= k && x <= i && x <= j && x <= k && 2 * x < i && 2 * x < j && 2 * x >= k) return cout << i << endl << j << endl << k << endl, 0; ; cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; void solve() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; if (2 * vm < v3) { cout << "-1"; return; } int s, m, x; s = max(v3, vm); m = max(2 * vm + 1, v2); x = max(m + 1, v1); if (s > 2 * v3 || m > 2 * v2 || x > 2 * v1) { cout << -1 << "\n"; return; } cout << x << "\n" << m << "\n" << s; } int main() { int t = 1; while (t--) { solve(); } 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; void solve() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; if (2 * vm < v3) { cout << "-1"; return; } int s, m, x; s = max(v3, vm); m = max(2 * vm + 1, v2); x = max(m + 1, v1); if (s > 2 * v3 || m > 2 * v2 || x > 2 * v1) { cout << -1 << "\n"; return; } cout << x << "\n" << m << "\n" << s; } int main() { int t = 1; while (t--) { solve(); } return 0; } ```
#include <bits/stdc++.h> int main() { int a[4]; int e = -1; for (int i = 0; i < 4; ++i) scanf("%d", &a[i]); if (a[3] < a[1]) { if ((a[2] > a[3] ? a[2] : a[3]) <= (2 * (a[2] > a[3] ? a[3] : a[2]))) { if ((2 * a[3]) >= a[1]) { a[1] = 2 * a[3] + 1; if (a[0] <= a[1]) a[0] = a[1] + 1; } printf("%d\n%d\n%d", a[0], a[1], (a[2] > a[3] ? a[2] : a[3])); } else printf("%d", e); } else printf("%d", e); }
### 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> int main() { int a[4]; int e = -1; for (int i = 0; i < 4; ++i) scanf("%d", &a[i]); if (a[3] < a[1]) { if ((a[2] > a[3] ? a[2] : a[3]) <= (2 * (a[2] > a[3] ? a[3] : a[2]))) { if ((2 * a[3]) >= a[1]) { a[1] = 2 * a[3] + 1; if (a[0] <= a[1]) a[0] = a[1] + 1; } printf("%d\n%d\n%d", a[0], a[1], (a[2] > a[3] ? a[2] : a[3])); } else printf("%d", e); } else printf("%d", e); } ```
#include <bits/stdc++.h> using namespace std; void solve() { long long a, b, c, d; cin >> c >> b >> a >> d; for (long long i = a; i <= 2 * a; i++) { for (long long j = max(b, a + 1); j <= 2 * b; j++) { for (long long k = max(c, j + 1); k <= 2 * c; k++) { if (d <= i && d <= j && d <= k && 2 * d >= i && 2 * d < j && 2 * d < k) { cout << k << '\n' << j << '\n' << i << '\n'; return; } } } } cout << -1; return; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t = 1, i = 1; while (t--) { 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; void solve() { long long a, b, c, d; cin >> c >> b >> a >> d; for (long long i = a; i <= 2 * a; i++) { for (long long j = max(b, a + 1); j <= 2 * b; j++) { for (long long k = max(c, j + 1); k <= 2 * c; k++) { if (d <= i && d <= j && d <= k && 2 * d >= i && 2 * d < j && 2 * d < k) { cout << k << '\n' << j << '\n' << i << '\n'; return; } } } } cout << -1; return; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t = 1, i = 1; while (t--) { solve(); } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (int a = v1; a < v1 * 2 + 1; a++) { for (int b = v2; b < min(a, v2 * 2 + 1); b++) { for (int c = v3; c < min(b, v3 * 2 + 1); c++) { if (c >= vm && 2 * vm >= c && 2 * vm < b) { cout << a << endl << b << endl << c << endl; return 0; } } } } 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; cin >> v1 >> v2 >> v3 >> vm; for (int a = v1; a < v1 * 2 + 1; a++) { for (int b = v2; b < min(a, v2 * 2 + 1); b++) { for (int c = v3; c < min(b, v3 * 2 + 1); c++) { if (c >= vm && 2 * vm >= c && 2 * vm < b) { cout << a << endl << b << endl << c << endl; return 0; } } } } cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int v1, v2, v3, vm, t, x1, x2; int main() { scanf("%d %d %d %d", &v1, &v2, &v3, &vm); x1 = v1 * 2; x2 = v2 * 2; t = x2; while (t >= 0) { if (2 * v3 >= t && 2 * vm >= t && t >= v3 && t >= vm && 2 * vm < x2 && vm <= x1 && vm <= x2) { printf("%d %d %d", x1, x2, t); return 0; } t--; } printf("-1"); 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, t, x1, x2; int main() { scanf("%d %d %d %d", &v1, &v2, &v3, &vm); x1 = v1 * 2; x2 = v2 * 2; t = x2; while (t >= 0) { if (2 * v3 >= t && 2 * vm >= t && t >= v3 && t >= vm && 2 * vm < x2 && vm <= x1 && vm <= x2) { printf("%d %d %d", x1, x2, t); return 0; } t--; } printf("-1"); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v_1, v_2, v_3, v_m, m_1, m_2, m_3; cin >> v_1 >> v_2 >> v_3 >> v_m; if (v_m >= v_2 || v_m < v_2 && v_m > v_3 && 2 * v_3 < v_m || v_m <= v_3 && 2 * v_m < v_3) { cout << -1; return 0; } cout << 2 * v_1 << "\n" << 2 * v_2 << "\n"; if (v_m > v_3) { cout << v_m; } else cout << v_3; 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 v_1, v_2, v_3, v_m, m_1, m_2, m_3; cin >> v_1 >> v_2 >> v_3 >> v_m; if (v_m >= v_2 || v_m < v_2 && v_m > v_3 && 2 * v_3 < v_m || v_m <= v_3 && 2 * v_m < v_3) { cout << -1; return 0; } cout << 2 * v_1 << "\n" << 2 * v_2 << "\n"; if (v_m > v_3) { cout << v_m; } else cout << v_3; return 0; } ```
#include <bits/stdc++.h> using namespace std; struct debugger { template <typename T> debugger& operator,(const T& v) { cout << v << " "; return *this; } } dbg; int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1}; int dy[] = {0, 0, 1, -1, -1, 1, -1, 1}; int main() { int t = 0, z = 0, len; int n = 0, k = 0, m = 0; int ans = 0; int a, b, c; scanf("%d %d %d", &a, &b, &c); scanf("%d", &m); for (int w = 0; w < 301; w++) { for (int x = 0; x < 301; x++) { for (int y = 0; y < 301; y++) { if (a <= w and 2 * a >= w) { if (b <= x and 2 * b >= x and x < w) { if (c <= y and 2 * c >= y and y < x) { if (m <= w and m <= x and m <= y and 2 * m >= y and !(2 * m >= w) and !(2 * m >= x)) { printf("%d", w); printf("\n"); printf("%d", x); printf("\n"); printf("%d", y); exit(0); } } } } } } } printf("%d", -1); 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; struct debugger { template <typename T> debugger& operator,(const T& v) { cout << v << " "; return *this; } } dbg; int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1}; int dy[] = {0, 0, 1, -1, -1, 1, -1, 1}; int main() { int t = 0, z = 0, len; int n = 0, k = 0, m = 0; int ans = 0; int a, b, c; scanf("%d %d %d", &a, &b, &c); scanf("%d", &m); for (int w = 0; w < 301; w++) { for (int x = 0; x < 301; x++) { for (int y = 0; y < 301; y++) { if (a <= w and 2 * a >= w) { if (b <= x and 2 * b >= x and x < w) { if (c <= y and 2 * c >= y and y < x) { if (m <= w and m <= x and m <= y and 2 * m >= y and !(2 * m >= w) and !(2 * m >= x)) { printf("%d", w); printf("\n"); printf("%d", x); printf("\n"); printf("%d", y); exit(0); } } } } } } } printf("%d", -1); 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); for (int i = 1; i <= 200; i++) for (int j = 1 + i; j <= 200; j++) for (int k = 1 + j; k <= 200; k++) { if (k >= v1 && 2 * v1 >= k && j >= v2 && v2 * 2 >= j && i >= v3 && v3 * 2 >= i && v4 <= i && v4 * 2 >= i && v4 * 2 < j) { printf("%d\n%d\n%d\n", k, j, i); return 0; } } 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, v4; scanf("%d%d%d%d", &v1, &v2, &v3, &v4); for (int i = 1; i <= 200; i++) for (int j = 1 + i; j <= 200; j++) for (int k = 1 + j; k <= 200; k++) { if (k >= v1 && 2 * v1 >= k && j >= v2 && v2 * 2 >= j && i >= v3 && v3 * 2 >= i && v4 <= i && v4 * 2 >= i && v4 * 2 < j) { printf("%d\n%d\n%d\n", k, j, i); return 0; } } printf("-1\n"); return 0; } ```
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a == 0) return b; return gcd(b % a, a); } long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } long long Abs(long long a) { if (a > 0) return a; return -a; } long long Ceil(long long a, long long b) { if (a % b == 0) return a / b; else return a / b + 1; } double Abs(double a) { if (a > 0) return a; return -a; } long long pow(long long x, long long y) { if (y == 0) return 1; long long tmp = pow(x, y / 2); if (y % 2 == 1) return ((tmp * tmp) * x); return (tmp * tmp); } int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); int a, b, c, d; cin >> a >> b >> c >> d; int s1, s2, s3; if (2 * d >= 2 * b || d > 2 * c || c > 2 * d) { cout << -1 << '\n'; return 0; } cout << 2 * a << "\n" << 2 * b << '\n' << 2 * min(c, d) << '\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; long long gcd(long long a, long long b) { if (a == 0) return b; return gcd(b % a, a); } long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } long long Abs(long long a) { if (a > 0) return a; return -a; } long long Ceil(long long a, long long b) { if (a % b == 0) return a / b; else return a / b + 1; } double Abs(double a) { if (a > 0) return a; return -a; } long long pow(long long x, long long y) { if (y == 0) return 1; long long tmp = pow(x, y / 2); if (y % 2 == 1) return ((tmp * tmp) * x); return (tmp * tmp); } int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); int a, b, c, d; cin >> a >> b >> c >> d; int s1, s2, s3; if (2 * d >= 2 * b || d > 2 * c || c > 2 * d) { cout << -1 << '\n'; return 0; } cout << 2 * a << "\n" << 2 * b << '\n' << 2 * min(c, d) << '\n'; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (int c1 = v1; c1 <= v1 * 2; c1++) for (int c2 = v2; c2 <= min(c1 - 1, v2 * 2); c2++) for (int c3 = v3; c3 <= min(c2 - 1, v3 * 2); c3++) { if (vm <= c1 && vm <= c2 && vm <= c3 && vm * 2 >= c3 && vm * 2 < c2 && vm * 2 < c1) { cout << c1 << "\n"; ; cout << c2 << "\n"; cout << c3 << "\n"; ; 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; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (int c1 = v1; c1 <= v1 * 2; c1++) for (int c2 = v2; c2 <= min(c1 - 1, v2 * 2); c2++) for (int c3 = v3; c3 <= min(c2 - 1, v3 * 2); c3++) { if (vm <= c1 && vm <= c2 && vm <= c3 && vm * 2 >= c3 && vm * 2 < c2 && vm * 2 < c1) { cout << c1 << "\n"; ; cout << c2 << "\n"; cout << c3 << "\n"; ; return 0; } } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; const long long INF = LLONG_MAX; const long long base = 1e9; const double PI = acos(-1); const long long MOD = 1e9 + 7; const long long N = 1e5 + 10; void logic() { long long v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (long long i = v1; i <= 2 * v1; i++) { for (long long j = v2; j <= 2 * v2; j++) { for (long long k = v3; k <= 2 * v3; k++) { if (i >= v1 and 2 * v1 >= i and j >= v2 and 2 * v2 >= j and k >= v3 and 2 * v3 >= k and vm <= k and 2 * vm >= k and i > j and j > k) { if (2 * vm < j and 2 * vm < i) { cout << i << endl << j << endl << k << endl; return; } } } } } cout << "-1" << endl; } int32_t main() { ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t = 1; for (long long i = 0; i < t; i++) { logic(); } 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; const long long INF = LLONG_MAX; const long long base = 1e9; const double PI = acos(-1); const long long MOD = 1e9 + 7; const long long N = 1e5 + 10; void logic() { long long v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (long long i = v1; i <= 2 * v1; i++) { for (long long j = v2; j <= 2 * v2; j++) { for (long long k = v3; k <= 2 * v3; k++) { if (i >= v1 and 2 * v1 >= i and j >= v2 and 2 * v2 >= j and k >= v3 and 2 * v3 >= k and vm <= k and 2 * vm >= k and i > j and j > k) { if (2 * vm < j and 2 * vm < i) { cout << i << endl << j << endl << k << endl; return; } } } } } cout << "-1" << endl; } int32_t main() { ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t = 1; for (long long i = 0; i < t; i++) { logic(); } return 0; } ```
#include <bits/stdc++.h> int main() { int father, mother, son, masha; int car1, car2, car3; scanf("%d %d %d %d", &father, &mother, &son, &masha); bool flag = false; for (car3 = ((son) > (masha) ? (son) : (masha)); car3 <= ((2 * son) > (2 * masha) ? (2 * masha) : (2 * son)) && flag == false; ++car3) { for (car2 = ((mother) > (((car3 + 1) > (2 * masha + 1) ? (car3 + 1) : (2 * masha + 1))) ? (mother) : (((car3 + 1) > (2 * masha + 1) ? (car3 + 1) : (2 * masha + 1)))); car2 <= 2 * mother && flag == false; ++car2) { for (car1 = ((father) > (((car2 + 1) > (2 * masha + 1) ? (car2 + 1) : (2 * masha + 1))) ? (father) : (((car2 + 1) > (2 * masha + 1) ? (car2 + 1) : (2 * masha + 1)))); car1 <= 2 * father && flag == false; ++car1) { flag = true; printf("%d\n%d\n%d", car1, car2, car3); } } } if (flag == false) { printf("-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> int main() { int father, mother, son, masha; int car1, car2, car3; scanf("%d %d %d %d", &father, &mother, &son, &masha); bool flag = false; for (car3 = ((son) > (masha) ? (son) : (masha)); car3 <= ((2 * son) > (2 * masha) ? (2 * masha) : (2 * son)) && flag == false; ++car3) { for (car2 = ((mother) > (((car3 + 1) > (2 * masha + 1) ? (car3 + 1) : (2 * masha + 1))) ? (mother) : (((car3 + 1) > (2 * masha + 1) ? (car3 + 1) : (2 * masha + 1)))); car2 <= 2 * mother && flag == false; ++car2) { for (car1 = ((father) > (((car2 + 1) > (2 * masha + 1) ? (car2 + 1) : (2 * masha + 1))) ? (father) : (((car2 + 1) > (2 * masha + 1) ? (car2 + 1) : (2 * masha + 1)))); car1 <= 2 * father && flag == false; ++car1) { flag = true; printf("%d\n%d\n%d", car1, car2, car3); } } } if (flag == false) { printf("-1"); } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long v1, v2, v3, v; cin >> v1 >> v2 >> v3 >> v; long long c = 0, i, j, k, a1, a2, a3; for (i = v3; i <= 2 * v3; i++) { for (j = v2; j <= 2 * v2; j++) { for (k = v1; k <= 2 * v1; k++) { if (k > j && j > i && i >= v && i <= 2 * v && j > 2 * v && k > 2 * v) { c = 1; a1 = k; a2 = j; a3 = i; break; } } } } if (c == 0) cout << "-1"; else { cout << a1 << "\n" << a2 << "\n" << a3; } 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() { long long v1, v2, v3, v; cin >> v1 >> v2 >> v3 >> v; long long c = 0, i, j, k, a1, a2, a3; for (i = v3; i <= 2 * v3; i++) { for (j = v2; j <= 2 * v2; j++) { for (k = v1; k <= 2 * v1; k++) { if (k > j && j > i && i >= v && i <= 2 * v && j > 2 * v && k > 2 * v) { c = 1; a1 = k; a2 = j; a3 = i; break; } } } } if (c == 0) cout << "-1"; else { cout << a1 << "\n" << a2 << "\n" << a3; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; int minn; while (~scanf("%d%d%d%d", &a, &b, &c, &d)) { if (d > 2 * c || d >= b || c > 2 * d) { cout << -1 << endl; } else cout << 2 * a << endl << 2 * b << endl << max(c, d) << endl; } 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 minn; while (~scanf("%d%d%d%d", &a, &b, &c, &d)) { if (d > 2 * c || d >= b || c > 2 * d) { cout << -1 << endl; } else cout << 2 * a << endl << 2 * b << endl << max(c, d) << endl; } return 0; } ```
#include <bits/stdc++.h> using namespace std; bool isSubSequence(string str1, string str2, int m, int n) { int j = 0; for (int i = 0; i < n && j < m; i++) { if (str1[j] == str2[i]) j++; } return (j == m); } int isPrime(long long n) { for (int i = 2; i <= sqrt(n) + 1; i++) if (n % i == 0) return 0; return 1; } int isSquare(long long n) { return (long long)sqrt(n) * (sqrt(n)) == n; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long i, j, n, l = 0, k = 0, cnt = 0, mini = 999999, maxi = -999999999, ans = 0; long long fa, mo, so, ma, ans1 = 0, ans2 = 0, ans3 = 0; cin >> fa >> mo >> so >> ma; for (i = fa; i < 2 * fa + 1; i++) { if (i >= ma && 2 * ma < i) { ans1 = i; } } if (ans1 == 0) return cout << -1, 0; for (i = mo; i < 2 * mo + 1; i++) { if (i >= ma && 2 * ma < i && i < ans1) { ans2 = i; } } if (ans2 == 0) return cout << -1, 0; for (i = so; i < 2 * so + 1; i++) { if (i >= ma && 2 * ma >= i) { ans3 = i; break; } } if (ans3 == 0) return cout << -1, 0; if (!(ans1 > ans2 && ans2 > ans3)) return cout << -1, 0; cout << ans1 << endl << ans2 << endl << ans3; 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; bool isSubSequence(string str1, string str2, int m, int n) { int j = 0; for (int i = 0; i < n && j < m; i++) { if (str1[j] == str2[i]) j++; } return (j == m); } int isPrime(long long n) { for (int i = 2; i <= sqrt(n) + 1; i++) if (n % i == 0) return 0; return 1; } int isSquare(long long n) { return (long long)sqrt(n) * (sqrt(n)) == n; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long i, j, n, l = 0, k = 0, cnt = 0, mini = 999999, maxi = -999999999, ans = 0; long long fa, mo, so, ma, ans1 = 0, ans2 = 0, ans3 = 0; cin >> fa >> mo >> so >> ma; for (i = fa; i < 2 * fa + 1; i++) { if (i >= ma && 2 * ma < i) { ans1 = i; } } if (ans1 == 0) return cout << -1, 0; for (i = mo; i < 2 * mo + 1; i++) { if (i >= ma && 2 * ma < i && i < ans1) { ans2 = i; } } if (ans2 == 0) return cout << -1, 0; for (i = so; i < 2 * so + 1; i++) { if (i >= ma && 2 * ma >= i) { ans3 = i; break; } } if (ans3 == 0) return cout << -1, 0; if (!(ans1 > ans2 && ans2 > ans3)) return cout << -1, 0; cout << ans1 << endl << ans2 << endl << ans3; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm, v1o, v2o; cin >> v1 >> v2 >> v3 >> vm; v1o = v1; v2o = v2; if (2 * v3 >= vm) { if (v3 <= 2 * vm) { while (1) { if (v1 <= 2 * vm) v1++; else break; } while (1) { if (v2 <= 2 * vm) v2++; else break; } while (1) { if (v1 <= v2) v1++; else break; } if (v1 <= 2 * v1o && v2 <= 2 * v2o) { cout << v1 << endl; cout << v2 << endl; if (v3 > vm) cout << v3 << endl; else cout << vm << endl; } else cout << -1 << endl; } else cout << -1 << 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; int main() { int v1, v2, v3, vm, v1o, v2o; cin >> v1 >> v2 >> v3 >> vm; v1o = v1; v2o = v2; if (2 * v3 >= vm) { if (v3 <= 2 * vm) { while (1) { if (v1 <= 2 * vm) v1++; else break; } while (1) { if (v2 <= 2 * vm) v2++; else break; } while (1) { if (v1 <= v2) v1++; else break; } if (v1 <= 2 * v1o && v2 <= 2 * v2o) { cout << v1 << endl; cout << v2 << endl; if (v3 > vm) cout << v3 << endl; else cout << vm << endl; } else cout << -1 << endl; } else cout << -1 << endl; } else cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (d > 2 * c || 2 * d < c || d >= b) { printf("-1\n"); return 0; } int tmp = max(c, d); cout << max(d * 2 + 2, a) << endl; cout << max(d * 2 + 1, b) << endl; cout << tmp << 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; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (d > 2 * c || 2 * d < c || d >= b) { printf("-1\n"); return 0; } int tmp = max(c, d); cout << max(d * 2 + 2, a) << endl; cout << max(d * 2 + 1, b) << endl; cout << tmp << endl; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int ans_br, ans_mom, ans_dad; if (d >= b || d > 2 * c) { cout << -1 << endl; } else { ans_br = max(d, c); if (ans_br > d * 2) { cout << -1 << endl; } else { ans_mom = max(max(b, 2 * d + 1), ans_br + 1); if (ans_mom > 2 * b) { cout << -1 << endl; } else { ans_dad = max(a, ans_mom + 1); if (ans_dad > 2 * a) { cout << -1 << endl; } else { cout << ans_dad << ' ' << ans_mom << ' ' << ans_br << 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 a, b, c, d; cin >> a >> b >> c >> d; int ans_br, ans_mom, ans_dad; if (d >= b || d > 2 * c) { cout << -1 << endl; } else { ans_br = max(d, c); if (ans_br > d * 2) { cout << -1 << endl; } else { ans_mom = max(max(b, 2 * d + 1), ans_br + 1); if (ans_mom > 2 * b) { cout << -1 << endl; } else { ans_dad = max(a, ans_mom + 1); if (ans_dad > 2 * a) { cout << -1 << endl; } else { cout << ans_dad << ' ' << ans_mom << ' ' << ans_br << endl; } } } } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int V1, V2, V3, Vm, a1, b1, a2, b2, a3, b3; cin >> V3 >> V2 >> V1 >> Vm; a1 = max(V1, Vm); a2 = max(a1 + 1, max(2 * Vm + 1, V2)); a3 = max(a2 + 1, max(2 * Vm + 1, V3)); b1 = 2 * min(V1, Vm); b2 = 2 * V2; b3 = 2 * V3; int s1, s2, s3; if (a1 > b1 || a2 > b2 || a3 > b3) cout << "-1"; else { cout << a3 << endl << a2 << endl << a1; } 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, Vm, a1, b1, a2, b2, a3, b3; cin >> V3 >> V2 >> V1 >> Vm; a1 = max(V1, Vm); a2 = max(a1 + 1, max(2 * Vm + 1, V2)); a3 = max(a2 + 1, max(2 * Vm + 1, V3)); b1 = 2 * min(V1, Vm); b2 = 2 * V2; b3 = 2 * V3; int s1, s2, s3; if (a1 > b1 || a2 > b2 || a3 > b3) cout << "-1"; else { cout << a3 << endl << a2 << endl << a1; } return 0; } ```
#include <bits/stdc++.h> long long max(long long A, long long b) { if (A > b) return A; return b; } long long min(long long A, long long b) { if (A < b) return A; return b; } using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; long long a, b, c; a = 2 * v1; b = 2 * v2; c = 2 * v3; c = min(c, 2 * v4); if (!(v3 <= c && v4 <= c && 2 * v3 >= c && 2 * v4 >= c && 2 * v4 < a && 2 * v4 < b)) { cout << -1 << endl; return 0; } cout << a << endl << b << endl << c << endl; }
### 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> long long max(long long A, long long b) { if (A > b) return A; return b; } long long min(long long A, long long b) { if (A < b) return A; return b; } using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; long long a, b, c; a = 2 * v1; b = 2 * v2; c = 2 * v3; c = min(c, 2 * v4); if (!(v3 <= c && v4 <= c && 2 * v3 >= c && 2 * v4 >= c && 2 * v4 < a && 2 * v4 < b)) { cout << -1 << endl; return 0; } cout << a << endl << b << endl << c << endl; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int a1, a2, a3, a4; cin >> a1 >> a2 >> a3 >> a4; for (int i = a1; i <= 2 * a1; i++) { for (int j = a2; j <= 2 * a2; j++) { for (int k = a3; k <= 2 * a3; k++) { if (i >= a4 and j >= a4 and k >= a4 and 2 * a4 >= k and i > j and j > k and 2 * a4 < j and 2 * a4 < i) { cout << i << endl << j << endl << k; return 0; } } } } cout << -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> using namespace std; int main() { ios_base::sync_with_stdio(false); int a1, a2, a3, a4; cin >> a1 >> a2 >> a3 >> a4; for (int i = a1; i <= 2 * a1; i++) { for (int j = a2; j <= 2 * a2; j++) { for (int k = a3; k <= 2 * a3; k++) { if (i >= a4 and j >= a4 and k >= a4 and 2 * a4 >= k and i > j and j > k and 2 * a4 < j and 2 * a4 < i) { cout << i << endl << j << endl << k; return 0; } } } } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int v1, v2, v3, v4; int main() { cin >> v1 >> v2 >> v3 >> v4; for (int i = v1; i <= v1 * 2; i++) { for (int j = v2; j <= v2 * 2; j++) { for (int k = v3; k <= v3 * 2; k++) { if (v4 <= k && v4 * 2 >= k && v4 * 2 < i && v4 * 2 < j && i >= v4 && j >= v4 && i > j && j > k) return cout << i << endl << j << endl << k << endl, 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 v1, v2, v3, v4; int main() { cin >> v1 >> v2 >> v3 >> v4; for (int i = v1; i <= v1 * 2; i++) { for (int j = v2; j <= v2 * 2; j++) { for (int k = v3; k <= v3 * 2; k++) { if (v4 <= k && v4 * 2 >= k && v4 * 2 < i && v4 * 2 < j && i >= v4 && j >= v4 && i > j && j > k) return cout << i << endl << j << endl << k << endl, 0; } } } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; scanf("%d", &v1); scanf("%d", &v2); scanf("%d", &v3); scanf("%d", &vm); int i, j, k; for (i = 1; i <= 400; i++) { for (j = 1; j <= 400; j++) { for (k = 1; k <= 400; k++) { if (v1 <= i and 2 * v1 >= i and v2 <= j and 2 * v2 >= j and v3 <= k and 2 * v3 >= k) { if (vm <= i and vm <= j and vm <= k) { if (2 * vm >= k and 2 * vm < j and 2 * vm < i and i > j and j > k) { 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, vm; scanf("%d", &v1); scanf("%d", &v2); scanf("%d", &v3); scanf("%d", &vm); int i, j, k; for (i = 1; i <= 400; i++) { for (j = 1; j <= 400; j++) { for (k = 1; k <= 400; k++) { if (v1 <= i and 2 * v1 >= i and v2 <= j and 2 * v2 >= j and v3 <= k and 2 * v3 >= k) { if (vm <= i and vm <= j and vm <= k) { if (2 * vm >= k and 2 * vm < j and 2 * vm < i and i > j and j > k) { cout << i << endl << j << endl << k << endl; return 0; } } } } } } cout << "-1" << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; class TaskA { public: void solve(std::istream& in, std::ostream& out) { int a, b, c, d; in >> a >> b >> c >> d; for (int small = c; small <= 2 * c; ++small) { for (int medium = b; medium <= 2 * b; ++medium) { for (int big = a; big <= 2 * a; ++big) { if (small < medium and medium < big and 2 * d >= small and 2 * d < medium and 2 * d < big and d <= small) { out << big << "\n" << medium << "\n" << small; return; } } } } out << -1; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); TaskA solver; std::istream& in(std::cin); std::ostream& out(std::cout); solver.solve(in, out); 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; class TaskA { public: void solve(std::istream& in, std::ostream& out) { int a, b, c, d; in >> a >> b >> c >> d; for (int small = c; small <= 2 * c; ++small) { for (int medium = b; medium <= 2 * b; ++medium) { for (int big = a; big <= 2 * a; ++big) { if (small < medium and medium < big and 2 * d >= small and 2 * d < medium and 2 * d < big and d <= small) { out << big << "\n" << medium << "\n" << small; return; } } } } out << -1; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); TaskA solver; std::istream& in(std::cin); std::ostream& out(std::cout); solver.solve(in, out); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; if (v4 > 2 * v3 || v3 > 2 * v4 || v4 >= v2) { cout << -1 << "\n"; return 0; } cout << 2 * v1 << "\n" << 2 * v2 << "\n" << max(v3, v4) << "\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() { int v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; if (v4 > 2 * v3 || v3 > 2 * v4 || v4 >= v2) { cout << -1 << "\n"; return 0; } cout << 2 * v1 << "\n" << 2 * v2 << "\n" << max(v3, v4) << "\n"; } ```
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const double EPS = 1e-9; const int INF = 1 << 29; int const NN = 2e5 + 5; bool f(int l, int r) { return l <= r; } int main() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; int l = max(v1, 2 * vm + 1); int r = 2 * v1; if (!f(l, r)) { puts("-1"); return 0; } int l1 = l, r1 = r; l = max(v2, 2 * vm + 1); r = 2 * v2; if (!f(l, r)) { puts("-1"); return 0; } int l2 = l, r2 = r; l = max(v3, vm); r = min(2 * v3, 2 * vm); if (!f(l, r)) { puts("-1"); return 0; } int l3 = l, r3 = r; for (int a = l1; a <= r1; ++a) { for (int b = l2; b <= r2; ++b) { for (int c = l3; c <= r3; ++c) { if (a > b && b > c) { cout << a; putchar('\n'); cout << b; putchar('\n'); cout << c; putchar('\n'); return 0; } } } } puts("-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 int mod = 1e9 + 7; const double EPS = 1e-9; const int INF = 1 << 29; int const NN = 2e5 + 5; bool f(int l, int r) { return l <= r; } int main() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; int l = max(v1, 2 * vm + 1); int r = 2 * v1; if (!f(l, r)) { puts("-1"); return 0; } int l1 = l, r1 = r; l = max(v2, 2 * vm + 1); r = 2 * v2; if (!f(l, r)) { puts("-1"); return 0; } int l2 = l, r2 = r; l = max(v3, vm); r = min(2 * v3, 2 * vm); if (!f(l, r)) { puts("-1"); return 0; } int l3 = l, r3 = r; for (int a = l1; a <= r1; ++a) { for (int b = l2; b <= r2; ++b) { for (int c = l3; c <= r3; ++c) { if (a > b && b > c) { cout << a; putchar('\n'); cout << b; putchar('\n'); cout << c; putchar('\n'); return 0; } } } } puts("-1"); return 0; } ```
#include <bits/stdc++.h> using namespace std; class pas { public: long long x, y; pas(long long x = 0, long long y = 0) : x(x), y(y) {} pas operator+(pas p) { return pas(x + p.x, y + p.y); } pas operator-(pas p) { return pas(x - p.x, y - p.y); } pas operator*(long long a) { return pas(x * a, y * a); } pas operator/(long long a) { return pas(x / a, y / a); } bool operator<(const pas &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const pas &p) const { return abs(x - p.x) == 0 && abs(y - p.y) == 0; } }; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(x * a, y * a); } Point operator/(double a) { return Point(x / a, y / a); } double absv() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point &p) const { return fabs(x - p.x) < (1e-10) && fabs(y - p.y) < (1e-10); } }; struct Segment { Point p1, p2; }; double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; } double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; } bool parareru(Point a, Point b, Point c, Point d) { return abs(cross(a - b, d - c)) < (1e-10); } double distance_ls_p(Point a, Point b, Point c) { if (dot(b - a, c - a) < (1e-10)) return (c - a).absv(); if (dot(a - b, c - b) < (1e-10)) return (c - b).absv(); return abs(cross(b - a, c - a)) / (b - a).absv(); } bool is_intersected_ls(Segment a, Segment b) { if (a.p1 == b.p1 || a.p2 == b.p1 || a.p1 == b.p2 || a.p2 == b.p2) return false; if (parareru((a.p2), (a.p1), (a.p1), (b.p2)) && parareru((a.p2), (a.p1), (a.p1), (b.p1))) { if (dot(a.p1 - b.p1, a.p1 - b.p2) < (1e-10)) return true; if (dot(a.p2 - b.p1, a.p2 - b.p2) < (1e-10)) return true; if (dot(a.p1 - b.p1, a.p2 - b.p1) < (1e-10)) return true; if (dot(a.p1 - b.p2, a.p2 - b.p2) < (1e-10)) return true; return false; } else return (cross(a.p2 - a.p1, b.p1 - a.p1) * cross(a.p2 - a.p1, b.p2 - a.p1) < (1e-10)) && (cross(b.p2 - b.p1, a.p1 - b.p1) * cross(b.p2 - b.p1, a.p2 - b.p1) < (1e-10)); } double segment_dis(Segment a, Segment b) { if (is_intersected_ls(a, b)) return 0; double r = distance_ls_p(a.p1, a.p2, b.p1); r = min(r, distance_ls_p(a.p1, a.p2, b.p2)); r = min(r, distance_ls_p(b.p1, b.p2, a.p2)); r = min(r, distance_ls_p(b.p1, b.p2, a.p1)); return r; } Point intersection_ls(Segment a, Segment b) { Point ba = b.p2 - b.p1; double d1 = abs(cross(ba, a.p1 - b.p1)); double d2 = abs(cross(ba, a.p2 - b.p1)); double t = d1 / (d1 + d2); return a.p1 + (a.p2 - a.p1) * t; } string itos(long long i) { ostringstream s; s << i; return s.str(); } long long gcd(long long v, long long b) { if (v > b) return gcd(b, v); if (v == b) return b; if (b % v == 0) return v; return gcd(v, b % v); } double distans(double x1, double y1, double x2, double y2) { double rr = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); return sqrt(rr); } long long pr[2000010]; long long inv[2000010]; long long beki(long long wa, long long rr, long long warukazu) { if (rr == 0) return 1ll; if (rr == 1) return wa % warukazu; if (rr % 2 == 1) return (beki(wa, rr - 1, warukazu) * wa) % warukazu; long long zx = beki(wa, rr / 2, warukazu); return (zx * zx) % warukazu; } void gya() { pr[0] = 1; for (long long i = 1; i < 2000010; i++) { pr[i] = (pr[i - 1] * i) % 1000000007; } for (long long i = 0; i < 2000010; i++) inv[i] = beki(pr[i], 1000000007 - 2, 1000000007); } long long par[200100], ranks[200100], kosuu[200100]; void shoki(long long n) { for (long long i = 0; i < n; i++) { par[i] = i; ranks[i] = 0; kosuu[i] = 1; } } long long root(long long x) { return par[x] == x ? x : par[x] = root(par[x]); } bool same(long long x, long long y) { return root(x) == root(y); } void unite(long long x, long long y) { x = root(x); y = root(y); long long xx = kosuu[x], yy = kosuu[y]; if (x == y) return; if (ranks[x] < ranks[y]) { par[x] = y; kosuu[y] = yy + xx; } else { par[y] = x; if (ranks[x] == ranks[y]) ranks[x] = ranks[x] + 1; kosuu[x] = yy + xx; } return; } long long a[40] = {0}; vector<long long> so; long long c[600], s[600], f[600]; signed main() { long long v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; long long a1, a2, a3; a1 = 2 * v1; a2 = 2 * v2; if (2 * vm >= a2) { cout << -1 << endl; return 0; } if (v3 >= vm) { a3 = v3; } if (v3 < vm) { a3 = 2 * v3; } if (!(2 * v3 >= a3 && a3 >= v3 && 2 * vm >= a3 && a3 >= vm)) { cout << -1 << endl; return 0; } cout << a1 << endl; cout << a2 << endl; cout << a3 << 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; class pas { public: long long x, y; pas(long long x = 0, long long y = 0) : x(x), y(y) {} pas operator+(pas p) { return pas(x + p.x, y + p.y); } pas operator-(pas p) { return pas(x - p.x, y - p.y); } pas operator*(long long a) { return pas(x * a, y * a); } pas operator/(long long a) { return pas(x / a, y / a); } bool operator<(const pas &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const pas &p) const { return abs(x - p.x) == 0 && abs(y - p.y) == 0; } }; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(x * a, y * a); } Point operator/(double a) { return Point(x / a, y / a); } double absv() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point &p) const { return fabs(x - p.x) < (1e-10) && fabs(y - p.y) < (1e-10); } }; struct Segment { Point p1, p2; }; double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; } double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; } bool parareru(Point a, Point b, Point c, Point d) { return abs(cross(a - b, d - c)) < (1e-10); } double distance_ls_p(Point a, Point b, Point c) { if (dot(b - a, c - a) < (1e-10)) return (c - a).absv(); if (dot(a - b, c - b) < (1e-10)) return (c - b).absv(); return abs(cross(b - a, c - a)) / (b - a).absv(); } bool is_intersected_ls(Segment a, Segment b) { if (a.p1 == b.p1 || a.p2 == b.p1 || a.p1 == b.p2 || a.p2 == b.p2) return false; if (parareru((a.p2), (a.p1), (a.p1), (b.p2)) && parareru((a.p2), (a.p1), (a.p1), (b.p1))) { if (dot(a.p1 - b.p1, a.p1 - b.p2) < (1e-10)) return true; if (dot(a.p2 - b.p1, a.p2 - b.p2) < (1e-10)) return true; if (dot(a.p1 - b.p1, a.p2 - b.p1) < (1e-10)) return true; if (dot(a.p1 - b.p2, a.p2 - b.p2) < (1e-10)) return true; return false; } else return (cross(a.p2 - a.p1, b.p1 - a.p1) * cross(a.p2 - a.p1, b.p2 - a.p1) < (1e-10)) && (cross(b.p2 - b.p1, a.p1 - b.p1) * cross(b.p2 - b.p1, a.p2 - b.p1) < (1e-10)); } double segment_dis(Segment a, Segment b) { if (is_intersected_ls(a, b)) return 0; double r = distance_ls_p(a.p1, a.p2, b.p1); r = min(r, distance_ls_p(a.p1, a.p2, b.p2)); r = min(r, distance_ls_p(b.p1, b.p2, a.p2)); r = min(r, distance_ls_p(b.p1, b.p2, a.p1)); return r; } Point intersection_ls(Segment a, Segment b) { Point ba = b.p2 - b.p1; double d1 = abs(cross(ba, a.p1 - b.p1)); double d2 = abs(cross(ba, a.p2 - b.p1)); double t = d1 / (d1 + d2); return a.p1 + (a.p2 - a.p1) * t; } string itos(long long i) { ostringstream s; s << i; return s.str(); } long long gcd(long long v, long long b) { if (v > b) return gcd(b, v); if (v == b) return b; if (b % v == 0) return v; return gcd(v, b % v); } double distans(double x1, double y1, double x2, double y2) { double rr = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); return sqrt(rr); } long long pr[2000010]; long long inv[2000010]; long long beki(long long wa, long long rr, long long warukazu) { if (rr == 0) return 1ll; if (rr == 1) return wa % warukazu; if (rr % 2 == 1) return (beki(wa, rr - 1, warukazu) * wa) % warukazu; long long zx = beki(wa, rr / 2, warukazu); return (zx * zx) % warukazu; } void gya() { pr[0] = 1; for (long long i = 1; i < 2000010; i++) { pr[i] = (pr[i - 1] * i) % 1000000007; } for (long long i = 0; i < 2000010; i++) inv[i] = beki(pr[i], 1000000007 - 2, 1000000007); } long long par[200100], ranks[200100], kosuu[200100]; void shoki(long long n) { for (long long i = 0; i < n; i++) { par[i] = i; ranks[i] = 0; kosuu[i] = 1; } } long long root(long long x) { return par[x] == x ? x : par[x] = root(par[x]); } bool same(long long x, long long y) { return root(x) == root(y); } void unite(long long x, long long y) { x = root(x); y = root(y); long long xx = kosuu[x], yy = kosuu[y]; if (x == y) return; if (ranks[x] < ranks[y]) { par[x] = y; kosuu[y] = yy + xx; } else { par[y] = x; if (ranks[x] == ranks[y]) ranks[x] = ranks[x] + 1; kosuu[x] = yy + xx; } return; } long long a[40] = {0}; vector<long long> so; long long c[600], s[600], f[600]; signed main() { long long v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; long long a1, a2, a3; a1 = 2 * v1; a2 = 2 * v2; if (2 * vm >= a2) { cout << -1 << endl; return 0; } if (v3 >= vm) { a3 = v3; } if (v3 < vm) { a3 = 2 * v3; } if (!(2 * v3 >= a3 && a3 >= v3 && 2 * vm >= a3 && a3 >= vm)) { cout << -1 << endl; return 0; } cout << a1 << endl; cout << a2 << endl; cout << a3 << endl; return 0; } ```
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; template <typename T> T max(T A) { return A; } template <typename T, typename... args> T max(T A, T B, args... S) { return max(A > B ? A : B, S...); } template <typename T> T min(T A) { return A; } template <typename T, typename... args> T min(T A, T B, args... S) { return min(A > B ? A : B, S...); } template <typename T> istream& operator>>(istream& in, vector<T>& v) { for (auto& x : v) scanf("%d", &x); return in; } template <typename T> ostream& operator<<(ostream& in, vector<T>& v) { for (auto& x : v) printf("%d ", x); return in; } long long fast(long long a, long long b, long long pr) { if (b == 0) return 1 % pr; long long ans = 1 % pr; while (b) { if (b & 1) { ans *= a; ans %= pr; } b >>= 1; a *= a; a %= pr; } return ans; } int readInt() { int n = 0; scanf("%d", &n); return n; int ch = getchar(); int sign = 1; while (ch < '0' || ch > '9') { if (ch == '-') sign = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') n = (n << 3) + (n << 1) + ch - '0', ch = getchar(); n = n * sign; return n; } long long inv_(long long val) { return fast(val, static_cast<long long>(1e9 + 7) - 2, static_cast<long long>(1e9 + 7)); } class solve { public: solve() { vector<int> v(4); cin >> v; vector<pair<int, int> > M; for (int i = 0; i < 4; i++) { M.push_back({v[i], 2 * v[i]}); } for (int i = 0; i < 2; i++) { if ((2 * v[3] >= M[i].second) && (v[3] <= M[i].second)) { cout << "-1"; return; } else if (M[i].second < v[3]) { cout << -1; return; } } for (int i = M[2].first; i <= M[2].second; i++) { if ((2 * v[3] >= i) && (v[3] <= i)) { cout << M[0].second << "\n" << M[1].second << "\n" << i << endl; return; } } cout << "-1"; } }; int32_t main() { int t = 1, i = 1; if (0) scanf("%d", &t); while (t--) { if (0) printf("Case #%d: ", i++); new solve; } 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 warning(disable : 4996) using namespace std; template <typename T> T max(T A) { return A; } template <typename T, typename... args> T max(T A, T B, args... S) { return max(A > B ? A : B, S...); } template <typename T> T min(T A) { return A; } template <typename T, typename... args> T min(T A, T B, args... S) { return min(A > B ? A : B, S...); } template <typename T> istream& operator>>(istream& in, vector<T>& v) { for (auto& x : v) scanf("%d", &x); return in; } template <typename T> ostream& operator<<(ostream& in, vector<T>& v) { for (auto& x : v) printf("%d ", x); return in; } long long fast(long long a, long long b, long long pr) { if (b == 0) return 1 % pr; long long ans = 1 % pr; while (b) { if (b & 1) { ans *= a; ans %= pr; } b >>= 1; a *= a; a %= pr; } return ans; } int readInt() { int n = 0; scanf("%d", &n); return n; int ch = getchar(); int sign = 1; while (ch < '0' || ch > '9') { if (ch == '-') sign = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') n = (n << 3) + (n << 1) + ch - '0', ch = getchar(); n = n * sign; return n; } long long inv_(long long val) { return fast(val, static_cast<long long>(1e9 + 7) - 2, static_cast<long long>(1e9 + 7)); } class solve { public: solve() { vector<int> v(4); cin >> v; vector<pair<int, int> > M; for (int i = 0; i < 4; i++) { M.push_back({v[i], 2 * v[i]}); } for (int i = 0; i < 2; i++) { if ((2 * v[3] >= M[i].second) && (v[3] <= M[i].second)) { cout << "-1"; return; } else if (M[i].second < v[3]) { cout << -1; return; } } for (int i = M[2].first; i <= M[2].second; i++) { if ((2 * v[3] >= i) && (v[3] <= i)) { cout << M[0].second << "\n" << M[1].second << "\n" << i << endl; return; } } cout << "-1"; } }; int32_t main() { int t = 1, i = 1; if (0) scanf("%d", &t); while (t--) { if (0) printf("Case #%d: ", i++); new solve; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v(4); for (int i = 0; i < 4; i++) { cin >> v[i]; } if (v[3] > v[2] * 2) { cout << "-1"; return 0; } if (v[2] > v[3] * 2) { cout << "-1"; return 0; } vector<int> s(3); for (int i = 0; i < 2; i++) { if (v[i] == v[3]) { cout << "-1"; return 0; } if (v[i] < v[3]) s[i] = v[i]; else s[i] = v[i] * 2; } if (v[2] > v[3]) s[2] = v[2]; else s[2] = v[3]; for (int i = 0; i < 3; i++) { cout << s[i] << 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() { vector<int> v(4); for (int i = 0; i < 4; i++) { cin >> v[i]; } if (v[3] > v[2] * 2) { cout << "-1"; return 0; } if (v[2] > v[3] * 2) { cout << "-1"; return 0; } vector<int> s(3); for (int i = 0; i < 2; i++) { if (v[i] == v[3]) { cout << "-1"; return 0; } if (v[i] < v[3]) s[i] = v[i]; else s[i] = v[i] * 2; } if (v[2] > v[3]) s[2] = v[2]; else s[2] = v[3]; for (int i = 0; i < 3; i++) { cout << s[i] << endl; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (!((2 * c) >= d) || d >= b || !((2 * d) >= c)) { cout << -1; return 0; } cout << 2 * a << endl << 2 * b << endl << 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; cin >> a >> b >> c >> d; if (!((2 * c) >= d) || d >= b || !((2 * d) >= c)) { cout << -1; return 0; } cout << 2 * a << endl << 2 * b << endl << max(c, d); return 0; } ```
#include <bits/stdc++.h> int main() { int v1, v2, v3, vM, s, r, p, c, d, e; scanf("%d%d%d%d", &v1, &v2, &v3, &vM); c = v1; d = v2; if (vM > (v3 * 2)) { printf("-1\n"); } else if ((vM * 2) < v3) { printf("-1\n"); } else { if (v3 > vM) { if ((v3 * 2) >= v1) { s = (v3 * 2) - v1; v1 = v1 + s + 1; } if ((v3 * 2) >= v2) { r = (v3 * 2) - v2; v2 = v2 + r + 1; if (v2 >= v1) { p = v2 - v1; v1 = v1 + p + 1; } } if ((c * 2) >= v1 && (d * 2) >= v2) { printf("%d\n%d\n%d\n", v1, v2, v3); } else { printf("-1\n"); } } else { if ((vM * 2) >= v1) { s = (vM * 2) - v1; v1 = v1 + s + 1; } if ((vM * 2) >= v2) { r = (vM * 2) - v2; v2 = v2 + r + 1; if (v2 >= v1) { p = v2 - v1; v1 = v1 + p + 1; } } if ((c * 2) >= v1 && (d * 2) >= v2) { printf("%d\n%d\n%d\n", v1, v2, vM); } else { 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> int main() { int v1, v2, v3, vM, s, r, p, c, d, e; scanf("%d%d%d%d", &v1, &v2, &v3, &vM); c = v1; d = v2; if (vM > (v3 * 2)) { printf("-1\n"); } else if ((vM * 2) < v3) { printf("-1\n"); } else { if (v3 > vM) { if ((v3 * 2) >= v1) { s = (v3 * 2) - v1; v1 = v1 + s + 1; } if ((v3 * 2) >= v2) { r = (v3 * 2) - v2; v2 = v2 + r + 1; if (v2 >= v1) { p = v2 - v1; v1 = v1 + p + 1; } } if ((c * 2) >= v1 && (d * 2) >= v2) { printf("%d\n%d\n%d\n", v1, v2, v3); } else { printf("-1\n"); } } else { if ((vM * 2) >= v1) { s = (vM * 2) - v1; v1 = v1 + s + 1; } if ((vM * 2) >= v2) { r = (vM * 2) - v2; v2 = v2 + r + 1; if (v2 >= v1) { p = v2 - v1; v1 = v1 + p + 1; } } if ((c * 2) >= v1 && (d * 2) >= v2) { printf("%d\n%d\n%d\n", v1, v2, vM); } else { printf("-1\n"); } } } return 0; } ```
#include <bits/stdc++.h> const long long LINF = 1e18; const int INF = 1e9; const int M = 1e9 + 7; const double EPS = 1e-9; using namespace std; int main() { std::ios_base::sync_with_stdio(0); int v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; int a1 = -1, a2 = -1, a3 = -1; for (int i = v1; i < 2 * v1 + 1; i++) if (2 * v4 < i) { a1 = i; } for (int i = v2; i < 2 * v2 + 1; i++) if (2 * v4 < i && i < a1) { a2 = i; } for (int i = v3; i < 2 * v3 + 1; i++) if (v4 <= i && 2 * v4 >= i && i < a2) { a3 = i; } if (a1 == -1 || a2 == -1 || a3 == -1) cout << -1; else cout << a1 << "\n" << a2 << "\n" << a3; 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> const long long LINF = 1e18; const int INF = 1e9; const int M = 1e9 + 7; const double EPS = 1e-9; using namespace std; int main() { std::ios_base::sync_with_stdio(0); int v1, v2, v3, v4; cin >> v1 >> v2 >> v3 >> v4; int a1 = -1, a2 = -1, a3 = -1; for (int i = v1; i < 2 * v1 + 1; i++) if (2 * v4 < i) { a1 = i; } for (int i = v2; i < 2 * v2 + 1; i++) if (2 * v4 < i && i < a1) { a2 = i; } for (int i = v3; i < 2 * v3 + 1; i++) if (v4 <= i && 2 * v4 >= i && i < a2) { a3 = i; } if (a1 == -1 || a2 == -1 || a3 == -1) cout << -1; else cout << a1 << "\n" << a2 << "\n" << a3; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int a, b, c, d; cin >> a >> b >> c >> d; int l1 = max(a - 1, 2 * d), l2 = max(b - 1, 2 * d); int l = max(c, d), r = min(2 * d, 2 * c); if (l1 >= 2 * a || l2 >= 2 * b || l > r || 2 * a <= l2 || 2 * a < l || 2 * b < l) cout << -1 << endl; else { cout << 2 * a << ' '; for (int i = l2 + 1; i <= 2 * b; i++) if (i > 2 * d) { cout << i << ' '; break; } cout << l << endl; } 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::sync_with_stdio(false); cin.tie(0); int a, b, c, d; cin >> a >> b >> c >> d; int l1 = max(a - 1, 2 * d), l2 = max(b - 1, 2 * d); int l = max(c, d), r = min(2 * d, 2 * c); if (l1 >= 2 * a || l2 >= 2 * b || l > r || 2 * a <= l2 || 2 * a < l || 2 * b < l) cout << -1 << endl; else { cout << 2 * a << ' '; for (int i = l2 + 1; i <= 2 * b; i++) if (i > 2 * d) { cout << i << ' '; break; } cout << l << endl; } return 0; } ```
#include <bits/stdc++.h> using namespace std; void solve() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; if (v3 > 2 * vm || vm > 2 * v3 || vm >= v2) cout << "-1" << endl; else { int m = v3 > vm ? v3 : vm; cout << v1 * 2 << endl << v2 * 2 << endl << m << endl; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); 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; void solve() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; if (v3 > 2 * vm || vm > 2 * v3 || vm >= v2) cout << "-1" << endl; else { int m = v3 > vm ? v3 : vm; cout << v1 * 2 << endl << v2 * 2 << endl << m << endl; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int x, y, z, xx, yy, zz; x = max(a, 2 * d + 1); xx = 2 * a; y = max(b, 2 * d + 1); yy = 2 * b; z = max(c, d); zz = min(2 * c, 2 * d); if (xx >= x && yy >= y && zz >= z) { for (int i = x; i <= xx; i++) { for (int j = y; j <= yy; j++) { for (int k = z; k <= zz; k++) { if (i > j && j > k) { cout << i << endl << j << endl << k << endl; return 0; } } } } } 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; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int x, y, z, xx, yy, zz; x = max(a, 2 * d + 1); xx = 2 * a; y = max(b, 2 * d + 1); yy = 2 * b; z = max(c, d); zz = min(2 * c, 2 * d); if (xx >= x && yy >= y && zz >= z) { for (int i = x; i <= xx; i++) { for (int j = y; j <= yy; j++) { for (int k = z; k <= zz; k++) { if (i > j && j > k) { cout << i << endl << j << endl << k << endl; return 0; } } } } } cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> int bsf(int x) { return __builtin_ctz(x); } int bsr(int x) { return 31 - __builtin_clz(x); } using namespace std; const double pi = 3.14159265358979323846; const int inf = (int)2e+9 + 2; const int mod = (int)1e+9 + 7; const double eps = 1e-8; const int N = 100000; int n, m, k; int v[4]; int ans[3]; void solve() { for (auto i = 0; i < 4; ++i) cin >> v[i]; ans[2] = max(v[2], v[3]); ans[1] = max(max(v[1], ans[2] + 1), v[3] * 2 + 1); ans[0] = max(v[0], ans[1] + 1); bool ok = true; for (auto i = 0; i < 3; ++i) { if (2 * v[i] < ans[i]) ok = false; } if (ok && 2 * v[3] >= ans[2]) { for (auto i = 0; i < 3; ++i) cout << ans[i] << '\n'; } else { cout << -1; } } int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int test = 1; for (; test; --test) solve(); 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> int bsf(int x) { return __builtin_ctz(x); } int bsr(int x) { return 31 - __builtin_clz(x); } using namespace std; const double pi = 3.14159265358979323846; const int inf = (int)2e+9 + 2; const int mod = (int)1e+9 + 7; const double eps = 1e-8; const int N = 100000; int n, m, k; int v[4]; int ans[3]; void solve() { for (auto i = 0; i < 4; ++i) cin >> v[i]; ans[2] = max(v[2], v[3]); ans[1] = max(max(v[1], ans[2] + 1), v[3] * 2 + 1); ans[0] = max(v[0], ans[1] + 1); bool ok = true; for (auto i = 0; i < 3; ++i) { if (2 * v[i] < ans[i]) ok = false; } if (ok && 2 * v[3] >= ans[2]) { for (auto i = 0; i < 3; ++i) cout << ans[i] << '\n'; } else { cout << -1; } } int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int test = 1; for (; test; --test) solve(); return 0; } ```
#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 (max(s, ma) > 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 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; 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 (max(s, ma) > 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; bool canClimb(int personSize, int carSize) { return personSize <= carSize; } bool likeIt(int personSize, int carSize) { return 2 * personSize >= carSize; } bool both(int personSize, int carSize) { return canClimb(personSize, carSize) && likeIt(personSize, carSize); } const int MAX_VAL = 201; void solve(int V1, int V2, int V3, int VM) { for (int a = 1; a <= MAX_VAL; a++) { for (int b = a + 1; b <= MAX_VAL; b++) { for (int c = b + 1; c <= MAX_VAL; c++) { if (both(V1, c) && both(V2, b) && both(V3, a) && canClimb(VM, a) && canClimb(VM, b) && canClimb(VM, c) && likeIt(VM, a) && !likeIt(VM, b) && !likeIt(VM, c)) { cout << c << '\n'; cout << b << '\n'; cout << a << '\n'; return; } } } } cout << -1 << '\n'; } int main() { int V1, V2, V3, VM; while (cin >> V1 >> V2 >> V3 >> VM) { solve(V1, V2, V3, VM); } }
### 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; bool canClimb(int personSize, int carSize) { return personSize <= carSize; } bool likeIt(int personSize, int carSize) { return 2 * personSize >= carSize; } bool both(int personSize, int carSize) { return canClimb(personSize, carSize) && likeIt(personSize, carSize); } const int MAX_VAL = 201; void solve(int V1, int V2, int V3, int VM) { for (int a = 1; a <= MAX_VAL; a++) { for (int b = a + 1; b <= MAX_VAL; b++) { for (int c = b + 1; c <= MAX_VAL; c++) { if (both(V1, c) && both(V2, b) && both(V3, a) && canClimb(VM, a) && canClimb(VM, b) && canClimb(VM, c) && likeIt(VM, a) && !likeIt(VM, b) && !likeIt(VM, c)) { cout << c << '\n'; cout << b << '\n'; cout << a << '\n'; return; } } } } cout << -1 << '\n'; } int main() { int V1, V2, V3, VM; while (cin >> V1 >> V2 >> V3 >> VM) { solve(V1, V2, V3, VM); } } ```
#include <bits/stdc++.h> using namespace std; long long i = 0, j = 0, k = 0; void solve() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (i = v1; i <= 2 * v1; ++i) { for (j = v2; j < 2 * v2 + 1; ++j) { for (k = v3; k <= 2 * v3; ++k) { if (vm < i && vm < j && vm <= k && 2 * vm >= k && i > 2 * vm && j > 2 * vm && i > j && j > k) { cout << i << endl << j << endl << k << endl; return; } } } } cout << -1; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int t = 1; while (t--) solve(); }
### 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; long long i = 0, j = 0, k = 0; void solve() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; for (i = v1; i <= 2 * v1; ++i) { for (j = v2; j < 2 * v2 + 1; ++j) { for (k = v3; k <= 2 * v3; ++k) { if (vm < i && vm < j && vm <= k && 2 * vm >= k && i > 2 * vm && j > 2 * vm && i > j && j > k) { cout << i << endl << j << endl << k << endl; return; } } } } cout << -1; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int t = 1; while (t--) solve(); } ```
#include <bits/stdc++.h> using namespace std; struct node { int idx, x, pa; }; int n; int main() { int v1, v2, v3, v4; scanf("%d %d %d %d", &v1, &v2, &v3, &v4); v1 *= 2; v2 *= 2; if (2 * v4 >= v2) { printf("-1\n"); return 0; } if (v3 > 2 * v4 || 2 * v3 < v4) { printf("-1\n"); return 0; } if (v3 >= v4) printf("%d\n%d\n%d\n", v1, v2, v3); else printf("%d\n%d\n%d\n", v1, v2, 2 * v3); 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; struct node { int idx, x, pa; }; int n; int main() { int v1, v2, v3, v4; scanf("%d %d %d %d", &v1, &v2, &v3, &v4); v1 *= 2; v2 *= 2; if (2 * v4 >= v2) { printf("-1\n"); return 0; } if (v3 > 2 * v4 || 2 * v3 < v4) { printf("-1\n"); return 0; } if (v3 >= v4) printf("%d\n%d\n%d\n", v1, v2, v3); else printf("%d\n%d\n%d\n", v1, v2, 2 * v3); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; int s1, s2, s3; if (vm <= 2 * v3 and 2 * vm >= v3 and vm < v2) { s1 = 2 * v1; s2 = 2 * v2; s3 = min({(2 * v3), v2 - 1, (2 * vm)}); cout << s1 << endl << s2 << endl << s3 << endl; } else cout << -1 << endl; }
### 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() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; int s1, s2, s3; if (vm <= 2 * v3 and 2 * vm >= v3 and vm < v2) { s1 = 2 * v1; s2 = 2 * v2; s3 = min({(2 * v3), v2 - 1, (2 * vm)}); cout << s1 << endl << s2 << endl << s3 << endl; } else cout << -1 << endl; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; int c1 = v1 * 2, c2 = v2 * 2, c3 = max(v3, vm); if ((vm * 2 >= c2 && vm <= c2) || (vm * 2 >= c1 && c1 >= vm)) { cout << -1 << endl; return 0; } if ((v3 * 2 >= c3 && v3 <= c3) && (vm * 2 >= c3 && vm <= c3)) cout << c1 << " " << c2 << " " << c3; 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; int main() { int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; int c1 = v1 * 2, c2 = v2 * 2, c3 = max(v3, vm); if ((vm * 2 >= c2 && vm <= c2) || (vm * 2 >= c1 && c1 >= vm)) { cout << -1 << endl; return 0; } if ((v3 * 2 >= c3 && v3 <= c3) && (vm * 2 >= c3 && vm <= c3)) cout << c1 << " " << c2 << " " << c3; 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); for (int i = a * 2; i >= a; i--) { if (i >= a && i <= a * 2) { a = i; break; } } for (int i = a - 1; i >= b; i--) { if (i >= b && i <= b * 2) { b = i; break; } } for (int i = b - 1; i >= max(c, d); i--) { if (i >= c && i <= c * 2 && i >= d && i <= d * 2 && c * 2 < b && c * 2 < a && d * 2 < b && d * 2 < a) { c = i; printf("%d\n%d\n%d\n", a, b, c); return 0; } } printf("%d\n", -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() { int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d); for (int i = a * 2; i >= a; i--) { if (i >= a && i <= a * 2) { a = i; break; } } for (int i = a - 1; i >= b; i--) { if (i >= b && i <= b * 2) { b = i; break; } } for (int i = b - 1; i >= max(c, d); i--) { if (i >= c && i <= c * 2 && i >= d && i <= d * 2 && c * 2 < b && c * 2 < a && d * 2 < b && d * 2 < a) { c = i; printf("%d\n%d\n%d\n", a, b, c); return 0; } } printf("%d\n", -1); return 0; } ```
#include <bits/stdc++.h> using namespace std; using ll = long long; enum {}; int main() { ios::sync_with_stdio(false); cin.tie(0); int v[3], vm; cin >> v[0] >> v[1] >> v[2] >> vm; int c[4]; c[3] = 0; for (c[0] = 1; c[0] <= 200; ++c[0]) { for (c[1] = 1; c[1] <= 200; ++c[1]) { for (c[2] = 1; c[2] <= 200; ++c[2]) { bool flag = true; for (int i = 0; i < 3; ++i) { flag &= c[i] >= max(vm, v[i]); flag &= 2 * v[i] >= c[i]; flag &= c[i] > c[i + 1]; } flag &= 2 * vm < c[0]; flag &= 2 * vm < c[1]; flag &= 2 * vm >= c[2]; if (flag) { for (int i = 0; i < 3; ++i) { cout << c[i] << '\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> using namespace std; using ll = long long; enum {}; int main() { ios::sync_with_stdio(false); cin.tie(0); int v[3], vm; cin >> v[0] >> v[1] >> v[2] >> vm; int c[4]; c[3] = 0; for (c[0] = 1; c[0] <= 200; ++c[0]) { for (c[1] = 1; c[1] <= 200; ++c[1]) { for (c[2] = 1; c[2] <= 200; ++c[2]) { bool flag = true; for (int i = 0; i < 3; ++i) { flag &= c[i] >= max(vm, v[i]); flag &= 2 * v[i] >= c[i]; flag &= c[i] > c[i + 1]; } flag &= 2 * vm < c[0]; flag &= 2 * vm < c[1]; flag &= 2 * vm >= c[2]; if (flag) { for (int i = 0; i < 3; ++i) { cout << c[i] << '\n'; } return 0; } } } } cout << "-1\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int a1 = a, a2 = b, a3 = c; if (d == a || d == b) { cout << -1; return 0; } if (a < d) a1 = a2 = a3 = d; else if (b < d) a2 = a3 = d; else if (c < d) a3 = d; if (2 * a < a1) a1 = 2 * a; if (2 * b < a2) a2 = 2 * b; if (2 * c < a3) a3 = 2 * c; if (2 * d >= a1) a1 = 2 * d + 1; if (2 * d >= a2) a2 = 2 * d + 1; if (2 * d < a3) a3 = 2 * d; if (a1 == a2) a1++; if (a1 == a3) a1++; if (a2 == a3) a2++; if (a1 < a || a2 < b || a3 < c || a1 < d || a2 < d || a3 < d) cout << -1; else cout << a1 << " " << a2 << " " << a3; 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 a, b, c, d; cin >> a >> b >> c >> d; int a1 = a, a2 = b, a3 = c; if (d == a || d == b) { cout << -1; return 0; } if (a < d) a1 = a2 = a3 = d; else if (b < d) a2 = a3 = d; else if (c < d) a3 = d; if (2 * a < a1) a1 = 2 * a; if (2 * b < a2) a2 = 2 * b; if (2 * c < a3) a3 = 2 * c; if (2 * d >= a1) a1 = 2 * d + 1; if (2 * d >= a2) a2 = 2 * d + 1; if (2 * d < a3) a3 = 2 * d; if (a1 == a2) a1++; if (a1 == a3) a1++; if (a2 == a3) a2++; if (a1 < a || a2 < b || a3 < c || a1 < d || a2 < d || a3 < d) cout << -1; else cout << a1 << " " << a2 << " " << a3; return 0; } ```
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y, long long int p = 1e9 + 7) { long long int res = 1; x = x % p; while (y > 0) { if (y & 1) { res = (res * x) % p; } x = (x * x) % p; y = y >> 1; } return res; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long int t; t = 1; while (t--) { long long int a, b, c, d, i; cin >> a >> b >> c >> d; long long int x = -1, y = -1, z = -1; for (i = a; i < 2 * a + 1; i++) { if (d <= i && 2 * d < i) { x = i; } } for (i = b; i < 2 * b + 1; i++) { if (d <= i && 2 * d < i) { y = i; break; } } for (i = c; i < 2 * c + 1; i++) { if (d <= i && 2 * d >= i) { z = i; break; } } if (x == -1 || y == -1 || z == -1) cout << -1; else cout << x << endl << y << endl << z; } 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; long long int power(long long int x, long long int y, long long int p = 1e9 + 7) { long long int res = 1; x = x % p; while (y > 0) { if (y & 1) { res = (res * x) % p; } x = (x * x) % p; y = y >> 1; } return res; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long int t; t = 1; while (t--) { long long int a, b, c, d, i; cin >> a >> b >> c >> d; long long int x = -1, y = -1, z = -1; for (i = a; i < 2 * a + 1; i++) { if (d <= i && 2 * d < i) { x = i; } } for (i = b; i < 2 * b + 1; i++) { if (d <= i && 2 * d < i) { y = i; break; } } for (i = c; i < 2 * c + 1; i++) { if (d <= i && 2 * d >= i) { z = i; break; } } if (x == -1 || y == -1 || z == -1) cout << -1; else cout << x << endl << y << endl << z; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int pb, mb, bb, m; cin >> pb >> mb >> bb >> m; int s1 = 2 * pb; int temp = 2 * m; if (2 * m >= s1) { cout << -1 << endl; return 0; } int s2 = 2 * mb; if (2 * m >= s2) { cout << -1 << endl; return 0; } int s3 = 2 * bb, c = 0; for (int i = bb; i <= s3; i++) { if (m <= i && temp >= i) { s3 = i; c = 1; break; } } if (c == 0) { cout << -1 << endl; return 0; } cout << s1 << endl; cout << s2 << endl; cout << s3 << 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 pb, mb, bb, m; cin >> pb >> mb >> bb >> m; int s1 = 2 * pb; int temp = 2 * m; if (2 * m >= s1) { cout << -1 << endl; return 0; } int s2 = 2 * mb; if (2 * m >= s2) { cout << -1 << endl; return 0; } int s3 = 2 * bb, c = 0; for (int i = bb; i <= s3; i++) { if (m <= i && temp >= i) { s3 = i; c = 1; break; } } if (c == 0) { cout << -1 << endl; return 0; } cout << s1 << endl; cout << s2 << endl; cout << s3 << endl; return 0; } ```
#include <bits/stdc++.h> int main(void) { int v1, v2, v3, v4; scanf("%d %d %d %d", &v1, &v2, &v3, &v4); for (int x = v1; x <= v1 * 2; x++) { for (int y = v2; y <= v2 * 2; y++) { for (int z = v3; z <= v3 * 2; z++) { if (x > y && y > z) { if (2 * v4 < y && 2 * v4 >= z) { if (v4 <= z) { printf("%d %d %d\n", x, y, z); 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> int main(void) { int v1, v2, v3, v4; scanf("%d %d %d %d", &v1, &v2, &v3, &v4); for (int x = v1; x <= v1 * 2; x++) { for (int y = v2; y <= v2 * 2; y++) { for (int z = v3; z <= v3 * 2; z++) { if (x > y && y > z) { if (2 * v4 < y && 2 * v4 >= z) { if (v4 <= z) { printf("%d %d %d\n", x, y, z); return 0; } } } } } } printf("-1\n"); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long v1, v2, v3, v4, i, j, k; cin >> v1 >> v2 >> v3 >> v4; for (i = 200; i >= 1; i--) for (j = i - 1; j >= 1; j--) for (k = j - 1; k >= 1; k--) if ((v1 <= i and v1 * 2 >= i) and (v2 <= j and v2 * 2 >= j) and (v3 <= k and v3 * 2 >= k) and (v4 <= k and v4 * 2 >= k) and (v4 > j or v4 * 2 < j) and (v4 > i or v4 * 2 < i)) { cout << i << endl << j << endl << k; return 0; } cout << -1; }
### 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() { long long v1, v2, v3, v4, i, j, k; cin >> v1 >> v2 >> v3 >> v4; for (i = 200; i >= 1; i--) for (j = i - 1; j >= 1; j--) for (k = j - 1; k >= 1; k--) if ((v1 <= i and v1 * 2 >= i) and (v2 <= j and v2 * 2 >= j) and (v3 <= k and v3 * 2 >= k) and (v4 <= k and v4 * 2 >= k) and (v4 > j or v4 * 2 < j) and (v4 > i or v4 * 2 < i)) { cout << i << endl << j << endl << k; return 0; } cout << -1; } ```
#include <bits/stdc++.h> int N; int main() { int a1, a2, a3, x, b1, b2, b3; scanf("%d%d%d%d", &a3, &a2, &a1, &x); for (b3 = a3; b3 <= 2 * a3; b3++) { for (b2 = a2; b2 <= 2 * a2; b2++) { for (b1 = a1; b1 <= 2 * a1; b1++) { if (b1 >= x && b2 >= x && b3 >= x && b1 <= 2 * x && b2 > 2 * x && b3 > 2 * x && b1 < b2 && b2 < b3) { printf("%d\n%d\n%d", b3, b2, b1); return 0; } } } } printf("-1"); }
### 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 N; int main() { int a1, a2, a3, x, b1, b2, b3; scanf("%d%d%d%d", &a3, &a2, &a1, &x); for (b3 = a3; b3 <= 2 * a3; b3++) { for (b2 = a2; b2 <= 2 * a2; b2++) { for (b1 = a1; b1 <= 2 * a1; b1++) { if (b1 >= x && b2 >= x && b3 >= x && b1 <= 2 * x && b2 > 2 * x && b3 > 2 * x && b1 < b2 && b2 < b3) { printf("%d\n%d\n%d", b3, b2, b1); return 0; } } } } printf("-1"); } ```
#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; long long u1, u2, u3; cin >> v1 >> v2 >> v3 >> vm; for (u1 = v1; u1 <= 2 * v1; u1++) { for (u2 = v2; u2 <= 2 * v2; u2++) { for (u3 = v3; u3 <= 2 * v3; u3++) { if (vm <= u3 && vm <= u2 && vm <= u1 && 2 * vm >= u3 && 2 * vm < u2 && 2 * vm < u1 && u1 > u2 && u2 > u3 && u1 > u3) { cout << u1 << '\n' << u2 << '\n' << u3; return 0; } } } } cout << "-1"; 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() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long v1, v2, v3, vm; long long u1, u2, u3; cin >> v1 >> v2 >> v3 >> vm; for (u1 = v1; u1 <= 2 * v1; u1++) { for (u2 = v2; u2 <= 2 * v2; u2++) { for (u3 = v3; u3 <= 2 * v3; u3++) { if (vm <= u3 && vm <= u2 && vm <= u1 && 2 * vm >= u3 && 2 * vm < u2 && 2 * vm < u1 && u1 > u2 && u2 > u3 && u1 > u3) { cout << u1 << '\n' << u2 << '\n' << u3; return 0; } } } } cout << "-1"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v[10]; cin >> v[1] >> v[2] >> v[3] >> v[4]; if (v[1] <= v[4] || v[2] <= v[4] || v[4] > 2 * v[3] || 2 * v[4] < v[3]) { cout << -1 << endl; } else { cout << 2 * v[1] << endl << 2 * v[2] << endl << max(v[4], v[3]) << endl; } }
### 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 v[10]; cin >> v[1] >> v[2] >> v[3] >> v[4]; if (v[1] <= v[4] || v[2] <= v[4] || v[4] > 2 * v[3] || 2 * v[4] < v[3]) { cout << -1 << endl; } else { cout << 2 * v[1] << endl << 2 * v[2] << endl << max(v[4], v[3]) << endl; } } ```
#include <bits/stdc++.h> using namespace std; int main(void) { int v[3], c[3], vm; cin >> v[2] >> v[1] >> v[0] >> vm; if (2 * vm < v[0] || 2 * v[0] < vm) { cout << "-1" << endl; return 0; } c[0] = max(v[0], vm); if (2 * v[1] <= c[0]) { cout << "-1" << endl; return 0; } c[1] = max(c[0] + 1, v[1]); if (c[1] <= vm * 2) { c[1] = vm * 2 + 1; } if (c[1] > v[1] * 2) { cout << "-1" << endl; return 0; } if (2 * v[2] <= c[1]) { cout << "-1" << endl; return 0; } c[2] = max(c[1] + 1, v[2]); cout << c[2] << endl; cout << c[1] << endl; cout << c[0] << 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(void) { int v[3], c[3], vm; cin >> v[2] >> v[1] >> v[0] >> vm; if (2 * vm < v[0] || 2 * v[0] < vm) { cout << "-1" << endl; return 0; } c[0] = max(v[0], vm); if (2 * v[1] <= c[0]) { cout << "-1" << endl; return 0; } c[1] = max(c[0] + 1, v[1]); if (c[1] <= vm * 2) { c[1] = vm * 2 + 1; } if (c[1] > v[1] * 2) { cout << "-1" << endl; return 0; } if (2 * v[2] <= c[1]) { cout << "-1" << endl; return 0; } c[2] = max(c[1] + 1, v[2]); cout << c[2] << endl; cout << c[1] << endl; cout << c[0] << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int f, m, c, ms; cin >> f >> m >> c >> ms; for (int F = f; F < (f << 1) + 1; F++) { for (int M = m; M < (m << 1) + 1; M++) { for (int L = min(c, ms); L < (max(c, ms) << 1) + 1; L++) { if (F > M && M > L) { if (c <= L && (c << 1) >= L && ms <= L && (ms << 1) >= L && F > (ms << 1) && M > (ms << 1)) { cout << F << " " << M << " " << L << 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 main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int f, m, c, ms; cin >> f >> m >> c >> ms; for (int F = f; F < (f << 1) + 1; F++) { for (int M = m; M < (m << 1) + 1; M++) { for (int L = min(c, ms); L < (max(c, ms) << 1) + 1; L++) { if (F > M && M > L) { if (c <= L && (c << 1) >= L && ms <= L && (ms << 1) >= L && F > (ms << 1) && M > (ms << 1)) { cout << F << " " << M << " " << L << endl; return 0; } } } } } cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int min_a = max(a, 2 * d - 1), min_b = max(b, 2 * d - 1), min_c = max(c, d); int max_a = 2 * a, max_b = 2 * b, max_c = min(2 * c, 2 * d); for (int i = min_a; i <= max_a; ++i) { for (int j = min_b; j <= max_b; ++j) { for (int c = min_c; c <= max_c; ++c) { if (i > j && j > c && i > 2 * d && j > 2 * d) { cout << i << "\n" << j << "\n" << c; 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 main() { int a, b, c, d; cin >> a >> b >> c >> d; int min_a = max(a, 2 * d - 1), min_b = max(b, 2 * d - 1), min_c = max(c, d); int max_a = 2 * a, max_b = 2 * b, max_c = min(2 * c, 2 * d); for (int i = min_a; i <= max_a; ++i) { for (int j = min_b; j <= max_b; ++j) { for (int c = min_c; c <= max_c; ++c) { if (i > j && j > c && i > 2 * d && j > 2 * d) { cout << i << "\n" << j << "\n" << c; return 0; } } } } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { iostream::sync_with_stdio(0); int a, b, c, d; cin >> a >> b >> c >> d; for (int i = a; i <= 200; i++) { for (int j = b; j <= 200; j++) { for (int k = 1; k <= 200; k++) { if (a * 2 >= i && b * 2 >= j && c <= k && c * 2 >= k && i > d * 2 && j > d * 2 && d <= k && d * 2 >= k && i > j && j > k) { cout << i << endl << j << endl << k << 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 main() { iostream::sync_with_stdio(0); int a, b, c, d; cin >> a >> b >> c >> d; for (int i = a; i <= 200; i++) { for (int j = b; j <= 200; j++) { for (int k = 1; k <= 200; k++) { if (a * 2 >= i && b * 2 >= j && c <= k && c * 2 >= k && i > d * 2 && j > d * 2 && d <= k && d * 2 >= k && i > j && j > k) { cout << i << endl << j << endl << k << endl; return 0; } } } } cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; if (max(v1, 2 * vm) >= 2 * v1 || max(v2, 2 * vm) >= 2 * v2 || max(v3, vm) > 2 * min(v3, vm)) cout << "-1"; else { cout << 2 * v1 << "\n"; cout << 2 * v2 << "\n"; cout << 2 * min(v3, vm) << "\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> #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; if (max(v1, 2 * vm) >= 2 * v1 || max(v2, 2 * vm) >= 2 * v2 || max(v3, vm) > 2 * min(v3, vm)) cout << "-1"; else { cout << 2 * v1 << "\n"; cout << 2 * v2 << "\n"; cout << 2 * min(v3, vm) << "\n"; } return 0; } ```
#include <bits/stdc++.h> using namespace std; template <typename T> inline void Int(T &n) { n = 0; int f = 1; register int ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1; for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0'; n = n * f; } template <typename T> T gcd(T a, T b) { return !b ? a : gcd(b, a % b); } template <typename T> inline void umin(T &a, T b) { a = a < b ? a : b; } template <typename T> inline void umax(T &a, T b) { a = a > b ? a : b; } template <typename T, typename W> inline void Int(T &x, W &y) { Int(x), Int(y); } template <typename T, typename W, typename Q> inline void Int(T &x, W &y, Q &z) { Int(x, y), Int(z); } const int N = (int)1e5 + 5; const int INF = (int)1e9 + 7; const long long MOD = (long long)1e9 + 7; int main() { int a, b, c, d; Int(a, b); Int(c, d); for (int i = d; i <= d * 2; ++i) if (i >= c and i <= c * 2 and b > d) { return !printf("%d\n%d\n%d\n", a * 2, b * 2, i); } 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> using namespace std; template <typename T> inline void Int(T &n) { n = 0; int f = 1; register int ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1; for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0'; n = n * f; } template <typename T> T gcd(T a, T b) { return !b ? a : gcd(b, a % b); } template <typename T> inline void umin(T &a, T b) { a = a < b ? a : b; } template <typename T> inline void umax(T &a, T b) { a = a > b ? a : b; } template <typename T, typename W> inline void Int(T &x, W &y) { Int(x), Int(y); } template <typename T, typename W, typename Q> inline void Int(T &x, W &y, Q &z) { Int(x, y), Int(z); } const int N = (int)1e5 + 5; const int INF = (int)1e9 + 7; const long long MOD = (long long)1e9 + 7; int main() { int a, b, c, d; Int(a, b); Int(c, d); for (int i = d; i <= d * 2; ++i) if (i >= c and i <= c * 2 and b > d) { return !printf("%d\n%d\n%d\n", a * 2, b * 2, i); } cout << -1 << '\n'; return 0; } ```
#include <bits/stdc++.h> using namespace std; int v1, v2, v3, vm, t; int main() { cin >> v1 >> v2 >> v3 >> vm; for (int i = v1; i <= 200; i++) for (int j = v2; j <= 200; j++) for (int h = v3; h <= 200; h++) { if (i > j && j > h) if (2 * v1 >= i) if (2 * v2 >= j) if (2 * v3 >= h) if (2 * vm >= h && vm <= h) if (2 * vm < i && 2 * vm < j) { cout << i << '\n' << j << '\n' << h; return 0; } } cout << -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 v1, v2, v3, vm, t; int main() { cin >> v1 >> v2 >> v3 >> vm; for (int i = v1; i <= 200; i++) for (int j = v2; j <= 200; j++) for (int h = v3; h <= 200; h++) { if (i > j && j > h) if (2 * v1 >= i) if (2 * v2 >= j) if (2 * v3 >= h) if (2 * vm >= h && vm <= h) if (2 * vm < i && 2 * vm < j) { cout << i << '\n' << j << '\n' << h; return 0; } } cout << -1; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; a = 2 * a; b = 2 * b; int k = 1; for (int i = c; i <= 2 * c; i++) { if (d <= i && 2 * d >= i) { k = 0; c = i; break; } } if (k == 0) { if (2 * d >= b || 2 * d >= a) { cout << "-1"; } else { cout << a << "\n" << b << "\n" << c; } } else cout << "-1"; }
### 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; cin >> a >> b >> c >> d; a = 2 * a; b = 2 * b; int k = 1; for (int i = c; i <= 2 * c; i++) { if (d <= i && 2 * d >= i) { k = 0; c = i; break; } } if (k == 0) { if (2 * d >= b || 2 * d >= a) { cout << "-1"; } else { cout << a << "\n" << b << "\n" << c; } } else cout << "-1"; } ```
#include <bits/stdc++.h> using namespace std; int main() { int k, l, m, n; cin >> k >> l >> m >> n; for (int i = k; i <= 2 * k; i++) { for (int j = l; j <= 2 * l; j++) { for (int x = m; x <= 2 * m; x++) { if (i > j && j > x) { if (n <= x && 2 * n >= x && 2 * n < j) { cout << i << "\n" << j << "\n" << x << endl; return 0; } } } } } 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; int main() { int k, l, m, n; cin >> k >> l >> m >> n; for (int i = k; i <= 2 * k; i++) { for (int j = l; j <= 2 * l; j++) { for (int x = m; x <= 2 * m; x++) { if (i > j && j > x) { if (n <= x && 2 * n >= x && 2 * n < j) { cout << i << "\n" << j << "\n" << x << endl; return 0; } } } } } cout << "-1" << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int p, m, s, ma; cin >> p >> m >> s >> ma; if (ma > s * 2 || ma >= m || s > 2 * ma) { cout << -1 << endl; } else { cout << 2 * p << endl << 2 * m << endl << max(s, ma) << 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 p, m, s, ma; cin >> p >> m >> s >> ma; if (ma > s * 2 || ma >= m || s > 2 * 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; long long v1, v2, v3, vm; int main() { cin >> v1 >> v2 >> v3 >> vm; for (int i = 1; i <= 500; i++) { for (int j = i + 1; j <= 500; j++) { for (int k = j + 1; k <= 500; k++) { if (v3 <= i && 2 * v3 >= i) { if (v2 <= j && v2 * 2 >= j) { if (v1 <= k && v1 * 2 >= k) { if (vm <= i && 2 * vm >= i && 2 * vm < j) { cout << k << endl; cout << j << endl; cout << i << endl; return 0; } } } } } } } 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; long long v1, v2, v3, vm; int main() { cin >> v1 >> v2 >> v3 >> vm; for (int i = 1; i <= 500; i++) { for (int j = i + 1; j <= 500; j++) { for (int k = j + 1; k <= 500; k++) { if (v3 <= i && 2 * v3 >= i) { if (v2 <= j && v2 * 2 >= j) { if (v1 <= k && v1 * 2 >= k) { if (vm <= i && 2 * vm >= i && 2 * vm < j) { cout << k << endl; cout << j << endl; cout << i << endl; return 0; } } } } } } } cout << -1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int savec = c; a *= 2; b = min(2 * b, a - 1); c = min(2 * c, b - 1); if (d * 2 >= a || d * 2 >= b) { printf("-1\n"); } else if (c >= d) { c = min(d * 2, c); if (c < savec) { printf("-1\n"); } else printf("%d\n%d\n%d\n", a, b, c); } else { printf("-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> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int savec = c; a *= 2; b = min(2 * b, a - 1); c = min(2 * c, b - 1); if (d * 2 >= a || d * 2 >= b) { printf("-1\n"); } else if (c >= d) { c = min(d * 2, c); if (c < savec) { printf("-1\n"); } else printf("%d\n%d\n%d\n", a, b, c); } else { printf("-1\n"); } 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) != 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 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() { 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> int main() { int b1, b2, b3, m; scanf("%d %d %d %d", &b1, &b2, &b3, &m); int cars[4]; bool flag = true; cars[0] = 2 * b1; cars[1] = 2 * b2; cars[2] = 2 * m < 2 * b3 ? 2 * m : 2 * b3; int temp = m + b3 - cars[2] / 2; if (m > cars[0] || m > cars[1] || cars[2] < temp) flag = false; if (2 * m >= cars[0] || 2 * m >= cars[1]) flag = false; if (flag) printf("%d\n%d\n%d\n", cars[0], cars[1], cars[2]); else printf("-1"); 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> int main() { int b1, b2, b3, m; scanf("%d %d %d %d", &b1, &b2, &b3, &m); int cars[4]; bool flag = true; cars[0] = 2 * b1; cars[1] = 2 * b2; cars[2] = 2 * m < 2 * b3 ? 2 * m : 2 * b3; int temp = m + b3 - cars[2] / 2; if (m > cars[0] || m > cars[1] || cars[2] < temp) flag = false; if (2 * m >= cars[0] || 2 * m >= cars[1]) flag = false; if (flag) printf("%d\n%d\n%d\n", cars[0], cars[1], cars[2]); else printf("-1"); return 0; } ```
#include <bits/stdc++.h> using namespace std; bool check(int c1, int c2, int c3, int v1, int v2, int v3, int m) { return (c1 >= v1 && c1 <= 2 * v1 && c2 >= v2 && c2 <= 2 * v2 && c3 >= v3 && c3 <= 2 * v3 && 2 * m >= c3 && 2 * m < c2 && c3 < c2 && c2 < c1 && m <= c3); } int main() { int v1, v2, v3, m; cin >> v1 >> v2 >> v3 >> m; for (int i = 1; i <= 200; i++) { for (int j = i + 1; j <= 200; j++) { for (int k = j + 1; k <= 200; k++) { if (check(k, j, i, v1, v2, v3, m)) { cout << k << endl; cout << j << endl; cout << i << endl; return 0; } } } } cout << -1 << endl; 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; bool check(int c1, int c2, int c3, int v1, int v2, int v3, int m) { return (c1 >= v1 && c1 <= 2 * v1 && c2 >= v2 && c2 <= 2 * v2 && c3 >= v3 && c3 <= 2 * v3 && 2 * m >= c3 && 2 * m < c2 && c3 < c2 && c2 < c1 && m <= c3); } int main() { int v1, v2, v3, m; cin >> v1 >> v2 >> v3 >> m; for (int i = 1; i <= 200; i++) { for (int j = i + 1; j <= 200; j++) { for (int k = j + 1; k <= 200; k++) { if (check(k, j, i, v1, v2, v3, m)) { cout << k << endl; cout << j << endl; cout << i << endl; return 0; } } } } cout << -1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const long long int MOD = 1e9 + 7; const int N = 1e6 + 6; long long int fact[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); read: int a, b, c, d, p, q, r; int ans = 1; cin >> a >> b >> c >> d; if (2 * d < c) ans = 0; else if (d > c) { if (d > 2 * c) ans = 0; else { r = d; q = 2 * r + 1; p = q + 1; if (b * 2 < q) ans = 0; if (a * 2 < p) ans = 0; } } else { r = c; q = 2 * r + 1; p = q + 1; if (b * 2 < q) ans = 0; if (a * 2 < p) ans = 0; } if (ans) { cout << max(p, a) << endl; cout << max(q, b) << endl; cout << r << endl; } else 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; const int INF = 1e9; const long long int MOD = 1e9 + 7; const int N = 1e6 + 6; long long int fact[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); read: int a, b, c, d, p, q, r; int ans = 1; cin >> a >> b >> c >> d; if (2 * d < c) ans = 0; else if (d > c) { if (d > 2 * c) ans = 0; else { r = d; q = 2 * r + 1; p = q + 1; if (b * 2 < q) ans = 0; if (a * 2 < p) ans = 0; } } else { r = c; q = 2 * r + 1; p = q + 1; if (b * 2 < q) ans = 0; if (a * 2 < p) ans = 0; } if (ans) { cout << max(p, a) << endl; cout << max(q, b) << endl; cout << r << endl; } else cout << -1 << endl; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (d > c * 2 || d >= b || d * 2 < c) { cout << "-1"; return 0; } cout << a * 2 << " " << b * 2 << " " << max(c, d); 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 a, b, c, d; cin >> a >> b >> c >> d; if (d > c * 2 || d >= b || d * 2 < c) { cout << "-1"; return 0; } cout << a * 2 << " " << b * 2 << " " << max(c, d); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int father, mother, son, masha; int fatherCarSize, motherCarSize, sonCarSize; cin >> father >> mother >> son >> masha; int flag = 1; if (masha > 2 * son) { flag = -1; } for (fatherCarSize = 2 * father; fatherCarSize >= father; fatherCarSize--) { if (masha * 2 < fatherCarSize && fatherCarSize <= father * 2) { break; } } if (fatherCarSize == father - 1) { flag = -1; } for (motherCarSize = fatherCarSize - 1; motherCarSize >= mother; motherCarSize--) { if (masha * 2 < motherCarSize && motherCarSize <= mother * 2) { break; } } if (motherCarSize == mother - 1) { flag = -1; } for (sonCarSize = motherCarSize - 1; sonCarSize >= son; sonCarSize--) { if (masha * 2 >= sonCarSize && sonCarSize <= son * 2) { break; } } if (sonCarSize == son - 1) { flag = -1; } if (flag == -1) { cout << -1; } else cout << fatherCarSize << endl << motherCarSize << endl << sonCarSize; 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 father, mother, son, masha; int fatherCarSize, motherCarSize, sonCarSize; cin >> father >> mother >> son >> masha; int flag = 1; if (masha > 2 * son) { flag = -1; } for (fatherCarSize = 2 * father; fatherCarSize >= father; fatherCarSize--) { if (masha * 2 < fatherCarSize && fatherCarSize <= father * 2) { break; } } if (fatherCarSize == father - 1) { flag = -1; } for (motherCarSize = fatherCarSize - 1; motherCarSize >= mother; motherCarSize--) { if (masha * 2 < motherCarSize && motherCarSize <= mother * 2) { break; } } if (motherCarSize == mother - 1) { flag = -1; } for (sonCarSize = motherCarSize - 1; sonCarSize >= son; sonCarSize--) { if (masha * 2 >= sonCarSize && sonCarSize <= son * 2) { break; } } if (sonCarSize == son - 1) { flag = -1; } if (flag == -1) { cout << -1; } else cout << fatherCarSize << endl << motherCarSize << endl << sonCarSize; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int car_1 = a; int car_2 = b; int car_3 = c; if (d <= 2 * c && 2 * d >= c) { if (d > c) car_3 = d; else car_3 = c; if (d * 2 >= car_2) car_2 = d * 2 + 1; if (car_2 > b * 2) { cout << "-1"; return 0; } if (car_2 < b) car_2 = b; if (car_2 >= car_1) car_1 = car_2 + 1; cout << car_1 << endl << car_2 << endl << car_3; } else { cout << "-1"; } 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 a, b, c, d; cin >> a >> b >> c >> d; int car_1 = a; int car_2 = b; int car_3 = c; if (d <= 2 * c && 2 * d >= c) { if (d > c) car_3 = d; else car_3 = c; if (d * 2 >= car_2) car_2 = d * 2 + 1; if (car_2 > b * 2) { cout << "-1"; return 0; } if (car_2 < b) car_2 = b; if (car_2 >= car_1) car_1 = car_2 + 1; cout << car_1 << endl << car_2 << endl << car_3; } else { cout << "-1"; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int father, mother, son, m; cin >> father >> mother >> son >> m; int x = 0, y = 0, z = 0; for (int i = father; i <= 200; ++i) { if (2 * father >= i && m <= i && 2 * m < i) { z = i; } } for (int i = mother; i < z; ++i) { if (2 * mother >= i && m <= i && 2 * m < i) { y = i; } } for (int i = 0; i < y; ++i) { if (2 * son >= i && son <= i && 2 * m >= i && m <= i) { x = i; } } if (x == 0 || y == 0 || z == 0) cout << -1 << endl; else { cout << z << endl; cout << y << endl; cout << x << endl; } }
### 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 father, mother, son, m; cin >> father >> mother >> son >> m; int x = 0, y = 0, z = 0; for (int i = father; i <= 200; ++i) { if (2 * father >= i && m <= i && 2 * m < i) { z = i; } } for (int i = mother; i < z; ++i) { if (2 * mother >= i && m <= i && 2 * m < i) { y = i; } } for (int i = 0; i < y; ++i) { if (2 * son >= i && son <= i && 2 * m >= i && m <= i) { x = i; } } if (x == 0 || y == 0 || z == 0) cout << -1 << endl; else { cout << z << endl; cout << y << endl; cout << x << endl; } } ```
#include <bits/stdc++.h> using namespace std; int main() { int a1, a2, a3, am; cin >> a1 >> a2 >> a3 >> am; int b1, b2, b3; b3 = max(am, a3); b2 = max(max(b3 + 1, a2), 2 * am + 1); b1 = max(b2 + 1, a1); if (b3 > 2 * a3 || b2 > 2 * a2 || b1 > 2 * a1 || b3 > 2 * am) { cout << -1 << endl; } else { cout << b1 << endl << b2 << endl << b3 << 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 a1, a2, a3, am; cin >> a1 >> a2 >> a3 >> am; int b1, b2, b3; b3 = max(am, a3); b2 = max(max(b3 + 1, a2), 2 * am + 1); b1 = max(b2 + 1, a1); if (b3 > 2 * a3 || b2 > 2 * a2 || b1 > 2 * a1 || b3 > 2 * am) { cout << -1 << endl; } else { cout << b1 << endl << b2 << endl << b3 << endl; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, v3, v4, x, y, z; cin >> v1 >> v2 >> v3 >> v4; if (!(v1 > v4 && v2 > v4)) { cout << "-1" << endl; return 0; } if ((2 * v4 < v3) || (2 * v3 < v4)) { cout << "-1" << endl; return 0; } if (v3 > v4) { z = 2 * v4; } else z = 2 * v3; x = 2 * v1; y = 2 * v2; cout << x << endl << y << endl << z << 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 v1, v2, v3, v4, x, y, z; cin >> v1 >> v2 >> v3 >> v4; if (!(v1 > v4 && v2 > v4)) { cout << "-1" << endl; return 0; } if ((2 * v4 < v3) || (2 * v3 < v4)) { cout << "-1" << endl; return 0; } if (v3 > v4) { z = 2 * v4; } else z = 2 * v3; x = 2 * v1; y = 2 * v2; cout << x << endl << y << endl << z << endl; } ```
#include <bits/stdc++.h> using namespace std; set<unsigned long long int>::iterator it; int main() { unsigned long long int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; unsigned long long int flag = 0; unsigned long long int ans; for (unsigned long long int i = v3; i <= 2 * v3; i++) { if (i >= vm && i <= 2 * vm) { flag = 1; ans = i; } } if (flag && 2 * v1 > 2 * vm && 2 * v2 > 2 * vm) { cout << 2 * v1 << " " << 2 * v2 << " " << ans << "\n"; } else 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; set<unsigned long long int>::iterator it; int main() { unsigned long long int v1, v2, v3, vm; cin >> v1 >> v2 >> v3 >> vm; unsigned long long int flag = 0; unsigned long long int ans; for (unsigned long long int i = v3; i <= 2 * v3; i++) { if (i >= vm && i <= 2 * vm) { flag = 1; ans = i; } } if (flag && 2 * v1 > 2 * vm && 2 * v2 > 2 * vm) { cout << 2 * v1 << " " << 2 * v2 << " " << ans << "\n"; } else cout << "-1\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; inline int read() { char c; int s = 0, t = 1; while (!isdigit(c = getchar())) if (c == '-') t = -1; do { s = s * 10 + c - '0'; } while (isdigit(c = getchar())); return s * t; } inline long long readl() { char c; long long s = 0; int t = 1; while (!isdigit(c = getchar())) if (c == '-') t = -1; do { s = s * 10 + c - '0'; } while (isdigit(c = getchar())); return s * t; } int n, m; int main() { int a, b, c, d; a = read(), b = read(), c = read(), d = read(); for (int i = c; i <= c * 2; i++) if (d <= i && d * 2 >= i) { if (d <= 2 * a && 2 * d >= 2 * a) continue; if (d <= 2 * b && 2 * d >= 2 * b) continue; printf("%d\n", 2 * a); printf("%d\n", 2 * b); printf("%d\n", i); return 0; } printf("%d\n", -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> using namespace std; inline int read() { char c; int s = 0, t = 1; while (!isdigit(c = getchar())) if (c == '-') t = -1; do { s = s * 10 + c - '0'; } while (isdigit(c = getchar())); return s * t; } inline long long readl() { char c; long long s = 0; int t = 1; while (!isdigit(c = getchar())) if (c == '-') t = -1; do { s = s * 10 + c - '0'; } while (isdigit(c = getchar())); return s * t; } int n, m; int main() { int a, b, c, d; a = read(), b = read(), c = read(), d = read(); for (int i = c; i <= c * 2; i++) if (d <= i && d * 2 >= i) { if (d <= 2 * a && 2 * d >= 2 * a) continue; if (d <= 2 * b && 2 * d >= 2 * b) continue; printf("%d\n", 2 * a); printf("%d\n", 2 * b); printf("%d\n", i); return 0; } printf("%d\n", -1); } ```