Codeforces Round #660 (Div. 2) A. Captain Flint and Crew Recruitment

题目链接

思路:

先算出来最小的三个近似质数,那么所组成的和最小就是31,小于31的都不能组成,另外因为不能重复,所以,36,40,44,都要特判一下,把14换成15就行了。

代码:

#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N=1e5+5;
const int M=2e4+5;
const double eps=1e-8;
const int mod=1e9+7;
const int inf=0x7fffffff;
const double pi=3.1415926;
using namespace std;
signed main()
{
	int t;
	cin>>t;
	while(t--)
    {
        int n,a,b,c,d;
		cin>>n;
		a=6;
		b=10;
		c=14;
		d=30;
		d=n-30;
		if(d==a||d==b||d==c)
        {
			c=15;
            d-=1;
			cout<<"YES"<<endl;
			cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
		}
		else if(d>0)
        {
			cout<<"YES"<<endl;
			cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
		}
		else
		{
		    cout<<"NO"<<endl;
		}
	}
	return 0;
}


猜你喜欢

转载自blog.csdn.net/ACkingdom/article/details/107737673
今日推荐