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).

Sample Input

Input
50 30 10 10
Output
50 30 10
Input
100 50 10 21
Output
-1

Hint

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.

 
题目意思:熊爸爸,熊妈妈,熊儿子各有一辆车,车的体积是c1,c2,c3,他们一家的体积是v1,v2,v3,Masha的体积是vm。
三辆车严格递减c1>c2>c3 。他们都喜欢各自的车满足条件vi<=ci<=2*vi。Masha三辆车都能进,但是他只喜欢最小的那辆车。
 
解题思路;
这道题很坑很坑,首先我们需要明确一点所给的是各自的体积,而要求的是汽车的体积!有用三层暴力的,其实在多种情况下只求一种,我们完全可以找一种边界情况,熊爸爸,熊妈妈不与Masha产生联系,还要严格递减,那么直接使用最大值就可以。c1=2*v1,c2=2*v2。但到了熊孩子就不一样了,他需要的车和Masha的需求产生了联系,Masha只喜欢最小的车而熊孩子也要最小车,这就使得我们需要对c3做一下判断。如果Masha体积很大,达到vm>2*v3,那么他将不能进入最小的车,不满足情况;但vm<=2*v3时,让c3等于熊孩子和Masha体积重最大的哪一个。这样c1,c2,c3找到了,接下来就是看是否符合条件了。
 我们要对所给的信息进行分析。
1.Masha三辆车都能进,那么一定有vm<=c3。
2.Masha要喜欢最小的那一辆车,那么还要满足2*vm>=c3
3.Masha只喜欢最小的那一辆,那么说明不喜欢最大的和中间大的,那么2*vm<c1,2*vm<c2。

 #include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long int LL;
const LL MAXL(1e6);
int main()
{
int v1,v2,v3,vm;
int c1,c2,c3;
while(~scanf("%d%d%d%d",&v1,&v2,&v3,&vm))
{
c1=*v1;
c2=*v2;
if(vm>*v3)
{
printf("-1\n");
return ;
}
c3=max(v3,vm);
if(vm<=c3&&*vm>=c3&&*vm<c2)
{
printf("%d\n%d\n%d\n",c1,c2,c3);
}
else
{
printf("-1\n");
}
}
return ;
}

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. O - Masha and Bears

    Problem description A family consisting of father bear, mother bear and son bear owns three cars. Fa ...

  3. Coloring a Tree(耐心翻译+思维)

    Description You are given a rooted tree with n vertices. The vertices are numbered from 1 to n, the ...

  4. Codeforces Round #524 (Div. 2) C. Masha and two friends(思维+计算几何?)

    传送门 https://www.cnblogs.com/violet-acmer/p/10146350.html 题意: 有一块 n*m 的棋盘,初始,黑白块相间排列,且左下角为白块. 给出两个区间[ ...

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

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

  6. Codeforces Round #454

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

  7. Codeforces 1304E 1-Trees and Queries (树上距离+思维)(翻译向)

    题意 给你一棵树,q个询问(x,y,a,b,k),每次问你如果在(x,y)加一条边,那么a到b能不能走k步,同一个点可以走多次 思路(翻译题解) 对于一条a到b的最短路径x,可以通过左右横跳的方法把他 ...

  8. Codeforces 643F - Bears and Juice(思维题)

    Codeforces 题目传送门 & 洛谷题目传送门 首先直接暴力枚举显然是不现实的,我们不妨换个角度来处理这个问题,考虑这 \(R_i\) 个瓶子中每一瓶被哪些熊在哪一天喝过. 我们考虑对这 ...

  9. B. Lord of the Values 思维数学建构 附加 英文翻译

    原题链接 Problem - 1523B - Codeforces 题目及部分翻译 While trading on(贸易,利用) his favorite exchange trader Willi ...

随机推荐

  1. 【js】Redux基本原理和使用

    Redux不是说任何的应用都要用到它,如果遇到了react解决不了得问题,可以考虑使用它. 例如: 用户的使用方式复杂不同身份的用户有不同的使用方式(比如普通用户和管理员)多个用户之间可以协作与服务器 ...

  2. 《算法竞赛进阶指南》0x10 基本数据结构 Hash

    Hash的基本知识 字符串hash算法将字符串看成p进制数字,再将结果mod q例如:abcabcdefg 将字母转换位数字(1231234567)=(1*p9+2*p8+3*p7+1*p6+2*p5 ...

  3. 1010 一元多项式求导(用while接收输入)

    题目: 知识点for me: 该题的输入并非是按回车后数据输入完毕也不是给定数据长度,而是输入到文件末尾.可以有以下三种写法: (1)while(cin>>a)  (2)while(sca ...

  4. Win10 64位+VS2015+Opencv3.3.0安装配置

    Win10 64位+VS2015+Opencv3.3.0安装配置 1.我们首先下载VS2015.OpenCV3.3.0. 1.1 VS2015下载 在官网https://visualstudio.mi ...

  5. 执行 sql 报错未缓冲查询,错误码 2014

    sql语句为 SELECT COUNT(id) AS tp_count FROM `tableName` WHERE `status` = 0 AND `source` = 1 AND ( `end_ ...

  6. Linux基础-2.目录文件的浏览、管理及维护

    1.Linux文件系统的层次结构 1)了解Linux文件系统的树状结构: 在Linux或UNIX操作系统中,所有的文件和目录都被组织成一个以根节点开始的倒置树状结构 2)掌握目录的定义:目录相当于Wi ...

  7. Angular4 自制分页控件

    过年后第一波,自制的分页控件,可能功能没有 PrimeNG 那么好,但是基本可以实现自定义翻页功能,包括:首页/最后一页/上一页/下一页. 用户可以自定义: 1. 当前默认页码(如未提供,默认为第一页 ...

  8. ElasticSearch优化系列四:ES的heap是如何被瓜分掉的

    以下分别解读几个我知道的内存消耗大户: Segment Memory Segment不是file吗?segment memory又是什么?前面提到过,一个segment是一个完备的lucene倒排索引 ...

  9. 使用CURL实现GET和POST方式请求

    /** 使用curl方式实现get或post请求@param $url 请求的url地址@param $data 发送的post数据 如果为空则为get方式请求return 请求后获取到的数据 */f ...

  10. Angular 7 版本

    Angular 7 版本 这是跨整个平台的主要版本,更新包括核心框架,Angular Material和CLI. 如何更新到v7 可以访问update.angular.io以获取有关更新应用程序的详细 ...