Masha and Bears(翻译+思维)
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 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).
Sample Input
50 30 10 10
50 30 10
100 50 10 21
-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.
我们要对所给的信息进行分析。
#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(翻译+思维)的更多相关文章
- CodeForces - 907A Masha and Bears
A. Masha and Bears time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- O - Masha and Bears
Problem description A family consisting of father bear, mother bear and son bear owns three cars. Fa ...
- Coloring a Tree(耐心翻译+思维)
Description You are given a rooted tree with n vertices. The vertices are numbered from 1 to n, the ...
- Codeforces Round #524 (Div. 2) C. Masha and two friends(思维+计算几何?)
传送门 https://www.cnblogs.com/violet-acmer/p/10146350.html 题意: 有一块 n*m 的棋盘,初始,黑白块相间排列,且左下角为白块. 给出两个区间[ ...
- Codeforces Round #454 Div. 2 A B C (暂时)
A. Masha and bears 题意 人的体积为\(V\),车的大小为\(size\),人能钻进车的条件是\(V\leq size\),人对车满意的条件是\(2V\geq size\). 现知道 ...
- Codeforces Round #454
Masha and Bears Tic-Tac-Toe Shockers Seating of Students Party Power Tower Reverses
- Codeforces 1304E 1-Trees and Queries (树上距离+思维)(翻译向)
题意 给你一棵树,q个询问(x,y,a,b,k),每次问你如果在(x,y)加一条边,那么a到b能不能走k步,同一个点可以走多次 思路(翻译题解) 对于一条a到b的最短路径x,可以通过左右横跳的方法把他 ...
- Codeforces 643F - Bears and Juice(思维题)
Codeforces 题目传送门 & 洛谷题目传送门 首先直接暴力枚举显然是不现实的,我们不妨换个角度来处理这个问题,考虑这 \(R_i\) 个瓶子中每一瓶被哪些熊在哪一天喝过. 我们考虑对这 ...
- B. Lord of the Values 思维数学建构 附加 英文翻译
原题链接 Problem - 1523B - Codeforces 题目及部分翻译 While trading on(贸易,利用) his favorite exchange trader Willi ...
随机推荐
- 傻瓜式搭建php+nginx+mysql服务器环境
1.安装nginx 1.安装yum源 rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0. ...
- 小程序中 function (res)的理解
刚看到小程序里面一段代码 success: function (res) { console.log('搜索结果:'); console.log(res); wx.hideToast(); if (r ...
- php 获取当前完整url地址
echo $url = $_SERVER["REQUEST_SCHEME"].'://'.$_SERVER["SERVER_NAME"].$_SERVER[&q ...
- 树莓派3B+学习笔记:7、挂载exfat格式U盘
树莓派的官方系统,默认不支持exfat格式U盘挂载. 插入exfat格式U盘会出现以下错误提示: 安装exfat-fuse后可以正常识别,需要在命令行执行以下命令,按“y”键回车确认: sudo ap ...
- 中国大学MOOC-JAVA学习(浙大翁恺)—— 信号报告
使用switch-case语句的练习 import java.util.Scanner; public class Main { public static void main(String[] ar ...
- 微信小程序-js为object添加属性
代码如下: var my_set = result.attributes.my_set; if (my_set == undefined) { my_set = { is_be_agree: e.de ...
- 在vim编辑器中实现python的tab补全
在vim编辑器中实现python的tab补全 在vim编辑器中实现python tab补全插件有Pydiction,Pydiction可以实现下面python代码的自动补全: 1.简单python ...
- R语言学习笔记(二十一五):如何如何提升R语言运算的性能以及速度
在R中获得快速运行代码的方法 使用向量化运算 R语言的并行计算可以用parallel和foreach包 加快R运行速度还可以使用cmpfun()函数即字节码编译器 再者就是在R中调用C或C++ 同时还 ...
- 20155330 实验三 敏捷开发与XP实践
20155330 实验三 敏捷开发与XP实践 实验内容 XP基础 XP核心实践 相关工具 实验步骤 (一)敏捷开发与XP 软件工程是把系统的.有序的.可量化的方法应用到软件的开发.运营和维护上的过程. ...
- 20155330 实验一《Java开发环境的熟悉》(Windows+IDEA)实验报告
实验知识点 JVM.JRE.JDK的安装位置与区别: 命令行运行javac:java:javac -cp; java -cp: PATH,CLASSPATH,SOURCEPATH的设定方法与应用: 包 ...