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.
其实这道题比较水,很多人都是因为没看懂题意,只要知道这道题的题意,写代码就好写很多了,也没有什么坑
题意:熊爸爸、熊妈妈和熊孩子一家三口去玩卡丁车(什么车不重要),玛莎是这里的负责人,她要去测试游客所使用的车,这里的车很多,规格也很对,而且车的大小也是根据使用者的大小而定的,而且车的大小在不小于使用者的大小的情况下,使用者才能使用,现在玛莎需要进入所有的车中进行测试,并且玛莎喜欢且仅喜欢最小的那辆车,现在已知熊爸爸、熊妈妈、熊孩子、玛莎的大小,问你是否存在一种方案,可以使熊爸爸、熊妈妈、熊孩子都希望找到一辆自己喜欢的车,而且玛莎也可以完成测试车辆的任务并且还喜欢最小的车(喜欢即为若使用者大小为a,那么车的大小为b,应满足a<=b<=2*a),如果有多种,输出任意一种,如果没有输出-1
分析:这道题看懂题意之后,就会感觉跟四个变量都有关,但是实际上只与三个有关,即v2、v3、vm,然后可以分成三种不可能存在可行车辆的情况:
1、当vm>=v2时,玛莎不可能只喜欢最小的那辆车了
2、当vm>2*c时,玛莎无法测试最小的那辆车了
3、当vm*2
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
int a,b,c,d;
while(~scanf("%d%d%d%d",&a,&b,&c,&d)){
if(b<=d||d>2*c||2*d<c) printf("-1\n");
else printf("%d\n%d\n%d\n",a*2,b*2,max(c,d));
}
return 0;}