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 ...
随机推荐
- java实现zabbix接口开发
API:https://www.zabbix.com/documentation/4.0/zh/manual/api/reference/user/login 如果你使用jar包开发的话,会出现*** ...
- HTML中放置CSS的三种方式和CSS选择器
(一)在HTML中使用CSS样式的方式一般有三种: 1 内联引用 2 内部引用 3 外部引用. 第一种:内联引用(也叫行内引用) 就是把CSS样式直接作用在HTML标签中. <p style ...
- Java常用修饰符总结
修饰符是用于限定类型以及类型成员申明的一种符号,可用于修饰类.变量和方法,分为访问修饰符和非访问修饰符.访问修饰符控制访问权限,不同的访问修饰符有不同的权限范围,而非访问修饰符则是提供一些特有功能. ...
- 控制台打印九九乘法表(for循环的使用)
控制台输出九九乘法表 for(int i=1;i<=9;i++){ for(int j = 1; j <= i; j ++) { System.out.print(j+"*&qu ...
- 前端提交表单两种验证方式记录 jq或h5 required属性
JQuery: <form id="form"> <input type="text" name="aaa"> &l ...
- js(jQuery)tips
一:页面加上$(function(){***内容***})与不加的区别 1.这个是DOM加载完之后再加载JS代码,你的JS如果放在文档后面可能一样,但是如果你要是把JS放在head里面就有差别了(放在 ...
- tp5多入口配置
手册里可能有写,但不是特别清晰,在这给个实例,有两种方式: 1.多个入口文件: 将public下的index.php复制一份,粘贴.重命名为对应模块的名字,如admin: 编辑admin.php的内容 ...
- 一种比使用协程更方便的方法:Invoke(),同样达到等待执行的效果
1.Invoke(string methodName,float time) 在一定时间调用methodName函数 using UnityEngine; using System.Collectio ...
- 树莓派3B+学习笔记:13、不间断会话服务screen
screen是一款能够实现多窗口远程控制的开源服务程序,简单来说就是为了解决网络异常中断或为了同时控制多个远程终端窗口而设计的程序.用户还可以使用screen服务程序同时在多个远程会话中自由切换,能够 ...
- 基于 FPGA 的 PCIE 总线 Linux 驱动设计
硬件平台 Kintex ®-7 family of FPGAs Intel X86 软件平台 Linux 4.15.0-36-generic #39~16.04.1-Ubuntu Xilinx xap ...