zoukankan      html  css  js  c++  java
  • Codeforces Round #656 (Div. 3) A. Three Pairwise Maximums(思维/构造)

    You are given three positive (i.e. strictly greater than zero) integers xx , yy and zz .

    Your task is to find positive integers aa , bb and cc such that x=max(a,b)x=max(a,b) , y=max(a,c)y=max(a,c) and z=max(b,c)z=max(b,c) , or determine that it is impossible to find such aa , bb and cc .

    You have to answer tt independent test cases. Print required aa , bb and cc in any (arbitrary) order.

    Input

    The first line of the input contains one integer tt (1≤t≤2⋅1041≤t≤2⋅104 ) — the number of test cases. Then tt test cases follow.

    The only line of the test case contains three integers xx , yy , and zz (1≤x,y,z≤1091≤x,y,z≤109 ).

    Output

    For each test case, print the answer:

    • "NO" in the only line of the output if a solution doesn't exist;
    • or "YES" in the first line and any valid triple of positive integers aa , bb and cc (1≤a,b,c≤1091≤a,b,c≤109 ) in the second line. You can print aa , bb and cc in any order.

    Example

    Input

    Copy

    5

    3 2 3

    100 100 100

    50 49 49

    10 30 20

    1 1000000000 1000000000

    Output

    Copy

    YES

    3 2 1

    YES

    100 100 100

    NO

    NO

    YES

    1 1 1000000000

    对三个数排一下序,三个等大的话直接输出,两等大一小的话除了这里面两个不同的数以外再构造一个1,其他情况都是不存在的。

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int t;
        cin >> t;
        while(t--)
        {
            int a[3];
            cin >> a[1] >> a[2] >> a[3];
            sort(a + 1, a +3 + 1);
            if(a[1] == a[2] && a[1] == a[3])
            {
                cout << "YES" <<endl;
                cout << a[1] << ' ' << a[2] << ' ' << a[3] << endl;
            }
            else if(a[2] == a[3])
            {
                cout << "YES" <<endl;
                cout << 1 << ' ' << a[1] << ' ' << a[3] << endl;
            }
            else cout << "NO" << endl;
        }
        return 0;
    }
  • 相关阅读:
    笔记44 Hibernate快速入门(一)
    tomcat 启用https协议
    笔记43 Spring Security简介
    笔记43 Spring Web Flow——订购披萨应用详解
    笔记42 Spring Web Flow——Demo(2)
    笔记41 Spring Web Flow——Demo
    Perfect Squares
    Factorial Trailing Zeroes
    Excel Sheet Column Title
    Excel Sheet Column Number
  • 原文地址:https://www.cnblogs.com/lipoicyclic/p/13336317.html
Copyright © 2011-2022 走看看