• 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;
    }
  • 相关阅读:
    java hashmap 缓存
    android 界面刷新 post send
    android 五种 布局文件
    通过枚举窗口,实现最小化到托盘中程序的窗口显示
    转 String,CString,TCHAR*,char*之间区别和联系
    标准C++ 时间日期函数
    话说程序员的职业生涯
    李开复:创业必备
    职业化的软件工程师
    让高版本ie兼容低版本
  • 原文地址:https://www.cnblogs.com/lipoicyclic/p/13336317.html
Copyright © 2020-2023  润新知