Problem description

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 V1V2V3Vm(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.

解题思路:假设一只熊的体积为V,一辆车的体积为C,则有如下三种情况:

①熊不能进去的车满足:V>C;

②熊能进去但不喜欢的车满足:V<2*V<C;

③熊能进去而且喜欢的车满足:V<=C<=2*V。

设三辆车的体积分别为C1、C2、C3,其关系严格递减即C1>C2>C3。父亲,母亲,儿子分别能进去和喜欢自己的车满足:Vi≤Ci≤2*Vi,(i=1,2,3)。

其中玛莎来做测试,要使玛莎能进去所有的车,则玛莎的体积只需不大于中等的车:Vm<=C3<V2<=C2;因为玛莎和儿子都喜欢体积最小的车,所以最小车的体积至少为max(Vm,V3)。如果Vm>=V3,此时最小车的体积为Vm,儿子能进去且喜欢它满足:2*V3>=C3>=Vm>=V3;如果Vm<V3,玛莎能进去且喜欢它满足:2*Vm>=C3>=V3>Vm。因此,不满足情况的有Vm>2*V3或者V3>2*Vm或者Vm>=V2,此时输出-1。否则输出C1、C2、C3的值。我们继续推导下去:以上已经求出最小车的体积为C3=max(Vm,V3);假设儿子的体积刚好为最小车的体积,则儿子能进去母亲的车但不能喜欢她的车满足:2*V3<=2*C3<C2,又V2<=C2<=2*V2,所以C2(min)=max(2*C3+1,V2)∈[C2,2*V2];同理可得母亲能进去父亲的车但不能喜欢他的车满足:V2<=C2<=2*V2<C1,又V1<=C1<=2*V1,所以C1(min)=max(2*V2+1,V1)∈[C1,2*V1]。

AC代码:

 #include<bits/stdc++.h>
using namespace std;
int main(){
int v1,v2,v3,vm;
cin>>v1>>v2>>v3>>vm;
if((vm>*v3)||(v3>*vm)||(vm>=v2))cout<<"-1"<<endl;
else{
v3=max(v3,vm);//v3为三辆车中最小的体积
cout<<max(*v2+,v1)<<"\n"<<max(*v3+,v2)<<"\n"<<v3<<endl;
}
return ;
}

O - Masha and Bears的更多相关文章

  1. CodeForces - 907A Masha and Bears

    A. Masha and Bears time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. Masha and Bears(翻译+思维)

    Description A family consisting of father bear, mother bear and son bear owns three cars. Father bea ...

  3. Codeforces Round #454 Div. 2 A B C (暂时)

    A. Masha and bears 题意 人的体积为\(V\),车的大小为\(size\),人能钻进车的条件是\(V\leq size\),人对车满意的条件是\(2V\geq size\). 现知道 ...

  4. Codeforces Round #454

    Masha and Bears Tic-Tac-Toe Shockers Seating of Students Party Power Tower Reverses

  5. codeforces 653D D. Delivery Bears(二分+网络流)

    题目链接: D. Delivery Bears time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  6. codeforces 887B Cubes for Masha 两种暴力

    B. Cubes for Masha time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  7. 【cf789B】Masha and geometric depression(分类讨论/暴力)

    B. Masha and geometric depression 题意 在黑板上写数列,首项是b,公比是q,超过l时就停止不写.给定m个数,遇到后跳过不写.问一共写多少个数,如果无穷个输出inf. ...

  8. 寒假集训——搜索 D - Cubes for Masha

    #include <stdio.h> #include <stdlib.h> #include <iostream> #include <string.h&g ...

  9. 524 (Div. 2) Masha and two friends

    Codeforces Round #524 (Div. 2) C. Masha and two friends 题目链接 题意:较为简单,初始给定这个白黑相交的格子,第一遍把坐标范围内的全部涂白,第二 ...

随机推荐

  1. 【sqli-labs】 less28 GET- Error based -All you Union&Select Belong to us -String -Single quote with parenthesis(GET型基于错误的去除了Union和Select的单引号带括号字符串型注入)

    这个不是基于错误的吧,看源码可以知道错误并没有输出 那就使用;%00和order by试一下 http://192.168.136.128/sqli-labs-master/Less-28/?id=1 ...

  2. 【sqli-labs】 less16 POST - Blind- Boolian/Time Based - Double quotes (基于bool型/时间延迟的双引号POST型盲注)

    ' or 1=1# -->失败 1" or 1=1# -->失败 1') or 1=1# -->失败 1") or 1=1# -->成功 判断为双引号变形注 ...

  3. java操作Excel的poi的导出Excel表格

    页面布局 点击导出用户:触发函数,直接访问后台 后台方法如下: public String export()throws Exception{ Connection con=null; try { c ...

  4. Markdown 常用语法总结

    注意:Markdown使用#.+.*等符号来标记,符号后面必须跟上至少跟上 1个空格才有效! Markdown的常用语法 标题 Markdown标题支持两种形式. 1.用#标记 在标题开头加上1~6个 ...

  5. Office 2013 提示找不到 Office.zh-cn\XXXXX

    1.先卸载Office 2013(已经卸载了的无视这一步)2.卸载Office 2013 后把C:\ProgramData\Microsoft\OFFICE文件删掉.3.删除下列注册信息1).依次点击 ...

  6. 【JavaScript】通过封装自己的JSONP解决浏览器的跨域问题(Ajax跨域)

    问题引出:要发送Ajax请求,就必须使用HTTP请求?什么是跨域问题? 什么是跨域问题:如果两个页面中的协议.域名.端口.子域名任意有一项不同,两者之间所进行的访问行动就是跨域的,而浏览器为了安全问题 ...

  7. 文件元数据、文件夹操作(day08)

    一.获取文件的元数据(meta data) 通过read write可以对文件的内容进行读写. 但是今天我们要操作的是文件的元数据(文件的属性信息) day08$ls -l hello -rw-rw- ...

  8. BZOJ 2006 [NOI2010]超级钢琴 (堆+主席树)

    题面:BZOJ传送门 洛谷传送门 让你求前$K$大的子序列和,$n\leq 5*10^{5}$ 只想到了个$nlog^{2}n$的做法,似乎要被卡常就看题解了.. 好神奇的操作啊,我傻了 我们把序列和 ...

  9. Golang - 并发编程

    目录 Golang - 并发编程 1. 并行和并发 2. go语言并发优势 3. goroutine是什么 4. 创建goroutine 5. runtime包 6. channel是什么 7. ch ...

  10. BZOJ 3930 Luogu P3172 选数 (莫比乌斯反演)

    手动博客搬家:本文发表于20180310 11:46:11, 原地址https://blog.csdn.net/suncongbo/article/details/79506484 题目链接: (Lu ...