CodeForces - 1388A Captain Flint and Crew Recruitment
Despite his bad reputation, Captain Flint is a friendly person (at least, friendly to animals). Now Captain Flint is searching worthy sailors to join his new crew (solely for peaceful purposes). A sailor is considered as worthy if he can solve Flint's task.
Recently, out of blue Captain Flint has been interested in math and even defined a new class of integers. Let's define a positive integer
Captain Flint guessed an integernnand asked you: can you represent it asthe sum of
Uncle Bogdan easily solved the task and joined the crew. Can you do the same?
Input
The first line contains a single integertt(1≤t≤10001≤t≤1000)— the number of test cases.
Nextttlines contain test cases— one per line. The first and only line of each test case contains the single integer
Output
For each test case print:
- YESand44differentpositive integers such that at least33of them are nearly prime and their sum is equal tonn(if there are multiple answers print any of them);
- NOif there is no way to representnnasthe sum of44different positiveintegerswhere at least33of them are nearly prime.
You can print each character ofYESorNOin any case.Example
Input7 7 23 31 36 44 100 258Output
NO NO YES 14 10 6 1 YES 5 6 10 15 YES 6 7 10 21 YES 2 10 33 55 YES 10 21 221 6
Note
In the first and second test cases, it can be proven that there are no four different positive integers such that at least three of them are nearly prime.
In the third test case,n=31=2⋅7+2⋅5+2⋅3+1n=31=2⋅7+2⋅5+2⋅3+1: integers1414,1010,66are nearly prime.
In the fourth test case,n=36=5+2⋅3+2⋅5+3⋅5n=36=5+2⋅3+2⋅5+3⋅5: integers66,1010,1515are nearly prime.
In the fifth test case,n=44=2⋅3+7+2⋅5+3⋅7n=44=2⋅3+7+2⋅5+3⋅7: integers66,1010,2121are nearly prime.
In the sixth test case,n=100=2+2⋅5+3⋅11+5⋅11n=100=2+2⋅5+3⋅11+5⋅11: integers1010,3333,5555are nearly prime.
In the seventh test case,n=258=2⋅5+3⋅7+13⋅17+2⋅3n=258=2⋅5+3⋅7+13⋅17+2⋅3: integers1010,2121,221221,66are nearly prime.
題目大意:儘管弗林特船長名聲不好,但他還是一個友好的人(至少對動物友好)。現在,弗林特上尉正在尋找值得的水手加入他的新船員(僅出於和平目的)。如果水手能夠解決弗林特的任務,他就被認為是值得的。 最近,發瘋的上尉弗林特(Flint)對數學感興趣,甚至定義了一類新的整數。如果可以將正整數x表示為p⋅q,則將其定義為近似質數,其中1 <p <q,並且p和q是質數。例如,整數6和10幾乎是質數(因為2⋅3=6和2⋅5=10),而整數1、3、4、16、17或44則不是。 弗林特船長猜到一個整數n並問您:您能否將其表示為4個不同的正整數之和,其中至少3個正整數應接近質數。 博格丹叔叔輕鬆解決了任務,並加入了機組人員。你能做得到嗎?
程式碼如下:
1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 using namespace std; 5 int main() 6 { 7 int t; 8 scanf("%d",&t); 9 for(int i=1;i<=t;i++) 10 { 11 int m; 12 scanf("%d",&m); 13 if(m>=31){ 14 if(m!=36&&m!=40&&m!=44) 15 printf("YES\n6 10 14 %d\n",m-30); 16 else printf("YES\n6 10 15 %d\n",m-31); 17 } 18 else{ 19 printf("NO\n"); 20 } 21 } 22 }