Topic background
Pig hanke got a chicken
Title Description
Pig Hanke particularly like to eat roast chicken (this is the same beast, fratricidal!) Hanke chicken is very special. Why special? Because he has 10 ingredients (mustard, cumin, etc.), you can put 1-3 grams of each ingredient, delicious chicken extent any of the quality of the ingredients and for all
Now, Hanke want to know, if you give a delicious degree, please output with the program all these 10 ingredients
Input and output formats
Input formats:
Row, n <= 5000
Output formats:
The first line, the total number of programs
To the end of the second row, the number 10 represents the release of each ingredient quality
According to lexicographic order.
If there is no way to meet the requirements, for as long as a "0" in the first line of output
Sample input and output
11
10 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1
Explanation
enumerate
Solution: Since n is relatively small, so the terrible cycle of violence such as the following
#include<cstdio> #include<iostream> #include<cmath> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; int n,ans; int main(){ //freopen("2089.in","r",stdin); //freopen("2089.out","w",stdout); scanf("%d",&n); for(int a1=1;a1<=3;a1++) for(int a2=1;a2<=3 ; A2 ++ ) For ( an int 3a , = 1 ; 3a , <= 3 ; 3a , ++ ) For ( an int Forum a4 = 1 ; Forum a4 <= 3 ; Forum a4 ++ ) For ( an int A5 = 1 ; A5 <= 3 ; A5 ++ ) For ( an int A6 = 1 ; A6 <= 3 ; ++ A6 ) For ( an int A7 = 1 ; A7 <= 3 ; ++ A7) for(int a8=1;a8<=3;a8++) for(int a9=1;a9<=3;a9++) for(int a10=1;a10<=3;a10++) if(a1+a2+a3+a4+a5+a6+a7+a8+a9+a10==n) ans++; cout<<ans<<endl; for( An int a1 's = 1 ; a1 's <= 3 ; a1 's ++ ) { For ( an int A2 = 1 ; A2 <= 3 ; A2 ++ ) { For ( an int 3a , = 1 ; 3a , <= 3 ; 3a , ++ ) { For ( an int Forum a4 = 1 ; Forum a4 <= 3 ; ++ Forum a4 ) { For ( an int A5 = 1 ; A5 <= 3 ; ++ A5 ) { For ( an int A6 = 1;a6<=3;a6++){ for(int a7=1;a7<=3;a7++){ for(int a8=1;a8<=3;a8++){ for(int a9=1;a9<=3;a9++){ for(int a10=1;a10<=3;a10++){ if(a1+a2+a3+a4+a5+a6+a7+a8+a9+a10==n) printf("%d %d %d %d %d %d %d %d %d %d\n", a1,a2,a3,a4,a5,a6,a7,a8,a9,a10); } } } } } } } } } } return 0; }