码迷,mamicode.com
首页 > 其他好文 > 详细

P2089 烤鸡

时间:2020-07-14 15:05:48      阅读:388      评论:0      收藏:0      [点我收藏+]

标签:for   com   target   结果   color   namespace   tps   include   else   

https://www.luogu.com.cn/problem/P2089

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int n, cnt=0, ans[60000][10];
 4 //最多情况是3^10= 59049,所以开60000二维数组,用二维数组存储结果 :第一维表示方案数,第二维存储该方案结果 
 5 int main()
 6 {
 7     
 8     cin>>n;
 9     if(n<10 || n>30)//去除0的情况 
10         cout<<0;
11     else
12     {
13         for(int a=1; a<=3; a++)
14             for(int b=1; b<=3; b++)
15                 for(int c=1; c<=3; c++)
16                     for(int d=1; d<=3; d++)
17                         for(int e=1; e<=3; e++)
18                             for(int f=1; f<=3; f++)
19                                 for(int g=1; g<=3; g++)
20                                     for(int h=1; h<=3; h++)
21                                         for(int i=1; i<=3; i++)
22                                             for(int j=1; j<=3; j++)
23                                                     if(a+b+c+d+e+f+g+h+i+j==n)//判断是否符合答案,并存储 
24                                                     {
25                                                         cnt++;
26                                                         ans[cnt][0]=a; ans[cnt][1]=b;
27                                                         ans[cnt][2]=c; ans[cnt][3]=d;
28                                                         ans[cnt][4]=e; ans[cnt][5]=f;
29                                                         ans[cnt][6]=g; ans[cnt][7]=h;
30                                                         ans[cnt][8]=i; ans[cnt][9]=j;
31                                                     }
32         cout<<cnt<<endl;//输出方案数和答案 
33         for(int i=1; i<=cnt; i++)
34         {
35             for(int j=0; j<10; j++)
36                 cout<<ans[i][j]<<" ";
37             cout<<endl;
38         }
39     }
40     
41     return 0;
42 }

 

P2089 烤鸡

标签:for   com   target   结果   color   namespace   tps   include   else   

原文地址:https://www.cnblogs.com/tflsnoi/p/13299079.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!