A. Sum of Three

原题链接

题解

要让abc不同,我们可以先固定ab取两个较小值,然后看看最大的 c 有没有重复

code

#include<bits/stdc++.h>
#define ll long long
using namespace std;

void solve()
{
    int n;
    cin>>n;
    if(n<7)
    {
        cout<<"NO\n";
        return;
    }
    if(n%3)
    {
        int a=1,b=2;
        int c=n-3;
        cout<<"YES\n";
        cout<<a<<' '<<b<<' '<<c<<'\n';
    }
    else
    {
        if(n<=9) cout<<"NO\n";
        else
        {
            cout<<"YES\n1 4 "<<n-5<<'\n';
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;
    while(t--) solve();
    return 0;
}

posted @ 2024-07-21 11:41  纯粹的  阅读(12)  评论(0)    收藏  举报