• CF A. Ichihime and Triangle 四月十五号


    A. Ichihime and Triangle
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Ichihime is the current priestess of the Mahjong Soul Temple. She claims to be human, despite her cat ears.

    These days the temple is holding a math contest. Usually, Ichihime lacks interest in these things, but this time the prize for the winner is her favorite — cookies. Ichihime decides to attend the contest. Now she is solving the following problem.

     

    You are given four positive integers aa, bb, cc, dd, such that abcda≤b≤c≤d.

    Your task is to find three integers xx, yy, zz, satisfying the following conditions:

    • axba≤x≤b.
    • bycb≤y≤c.
    • czdc≤z≤d.
    • There exists a triangle with a positive non-zero area and the lengths of its three sides are xx, yy, and zz.

    Ichihime desires to get the cookie, but the problem seems too hard for her. Can you help her?

    Input

    The first line contains a single integer tt (1t10001≤t≤1000)  — the number of test cases.

    The next tt lines describe test cases. Each test case is given as four space-separated integers aa, bb, cc, dd (1abcd1091≤a≤b≤c≤d≤109).

    Output

    For each test case, print three integers xx, yy, zz  — the integers you found satisfying the conditions given in the statement.

    It is guaranteed that the answer always exists. If there are multiple answers, print any.

    Example
    input
    Copy
    4
    1 3 5 7
    1 5 5 7
    100000 200000 300000 400000
    1 1 977539810 977539810
    
    output
    Copy
    3 4 5
    5 5 5
    182690 214748 300999
    1 977539810 977539810
    
    Note

    One of the possible solutions to the first test case:

    One of the possible solutions to the second test case:

     

    题意:就给四个数,分成三段,每一段选一个数,必须要能够形成三角形;

    根据小学的知识,我们可以知道,三角形的两边和必须大于第三边;

    这题很重要的一点是端点都是可以等于的,那么倘若三角形两条边相同的话,第三边无论是多少,都可以成立:

     1 #include <bits/stdc++.h>
     2 const int maxn=1e5+50;
     3 const int INF=0x3f3f3f3f;
     4 using namespace std;
     5 int main(){
     6     int t;
     7     cin>>t;
     8 while(t--){
     9     int a,b,c,d;
    10     cin>>a>>b>>c>>d;
    11     cout<<a<<" "<<c<<" "<<c<<'
    '; 
    12     //或者cout<<b<<" "<<b<<" "<<c<<'
    ';
    13 } 
    14 
    15 return 0;
    16 }
  • 相关阅读:
    mwutil公用方法库——dateTool
    mwutil公用方法库文档——cookieTool
    mwutil 公用方法库文档 ——arrayTool
    localstorage封装!
    github commit 规范
    你好,C++(40)7.1 一切指针都是纸老虎:彻底理解指针
    你好,C++(39)6.4.4 依葫芦画瓢:用C++表达设计结果(下)
    你好,C++(38)从问题描述中发现对象的属性和行为 6.4 工资程序成长记:类与对象(上)
    你好,C++(37)上车的人请买票!6.3.3 用虚函数实现多态
    你好,C++(36)人参再好,也不能当饭吃!6.3 类是如何面向对象的
  • 原文地址:https://www.cnblogs.com/ahijing/p/12724418.html
Copyright © 2020-2023  润新知