zoukankan      html  css  js  c++  java
  • CodeForces

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

    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.

    题目链接 

    分析 

    水题,但有个坑点,就是Masha只like最小的车,就是说2*Vm<v2。

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<cstdlib>
    #include<algorithm>
    #include<cstring>
    #include<queue>
    using namespace std;
    typedef long long LL;
    const int maxn = 1e4+5;
    const int mod = 772002+233;
    typedef pair<int,int> pii;
    #define X first
    #define Y second
    #define pb push_back
    #define mp make_pair
    #define ms(a,b) memset(a,b,sizeof(a))
    
    int main(){
    //    freopen("in.txt","r",stdin);
        int v1,v2,v3,vm;
        scanf("%d%d%d%d",&v1,&v2,&v3,&vm);
    
        if(vm>2*v3||v3>2*vm||v2<=vm){
            cout<<-1<<endl;
        }else{
    
            cout<<2*v1<<endl<<2*v2<<endl<<max(v3,vm)<<endl;
    
        }
        return 0;
    }
  • 相关阅读:
    Serverless 解惑——函数计算如何访问 MySQL 数据库
    Kubernetes 会不会“杀死” DevOps?
    开发函数计算的正确姿势——使用交互模式安装依赖
    从零开始入门 K8s | 调度器的调度流程和算法介绍
    eclipse中如何自动生成构造函数
    微服务架构中API网关的角色
    JAVA设计模式之责任链模式
    谦先生的程序员日志之我的hadoop大数据生涯一
    谦先生的bug日志之hive启动权限问题
    CSS盒子模型之详解
  • 原文地址:https://www.cnblogs.com/fht-litost/p/8552918.html
Copyright © 2011-2022 走看看