Masha and Bears

本文介绍了一个趣味编程问题,涉及不同大小的熊与对应的汽车大小匹配问题。通过数学逻辑判断,找到符合所有人喜好的汽车大小组合。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Masha and Bears


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.

给定体重w,能进入这辆车车的大小要求szie >= w,如果这个人还喜欢这辆车需要满足 w <= size <= 2*w

题目给定a,b,c,d四个人重量,abc喜欢各自的车,并且a>b>c,d能进去abc的三辆车car1,car2,car3并且只喜欢第三辆车,求满足条件的三辆车的大小

首先从喜欢car3入手,所以必须满足  c <= d <= 2*c,即如果d > 2*c || 2*d < c不行,第一个不等式好说,第二个容易写错,因为car3的大小在c~2*c 所以只要2*d能在这个范围内就能保证喜欢这辆车,其次对于car2,如果d < b我们让car2取最大2*b就可以满足不喜欢car2,那么同理最大的车car1也取最大值2*a就可以了,第三辆车输出max(d,c)

code:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(d > 2 * c || c > 2 * d || d >= b)
        printf("-1\n");
    else
        printf("%d\n%d\n%d\n",2*a,2*b,max(c,d));
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值