做百度网站找谁,js网页设计大作业源代码,wordpress识别环境的文件,韩国小游戏网站烤鸡
题目背景
猪猪 Hanke 得到了一只鸡。
题目描述
猪猪 Hanke 特别喜欢吃烤鸡#xff08;本是同畜牲#xff0c;相煎何太急#xff01;#xff09;Hanke 吃鸡很特别#xff0c;为什么特别呢#xff1f;因为他有 10 10 10 种配料#xff08;芥末、孜然等#xff…烤鸡
题目背景
猪猪 Hanke 得到了一只鸡。
题目描述
猪猪 Hanke 特别喜欢吃烤鸡本是同畜牲相煎何太急Hanke 吃鸡很特别为什么特别呢因为他有 10 10 10 种配料芥末、孜然等每种配料可以放 1 1 1 到 3 3 3 克任意烤鸡的美味程度为所有配料质量之和。
现在 Hanke 想要知道如果给你一个美味程度 n n n 请输出这 10 10 10 种配料的所有搭配方案。
输入格式
一个正整数 n n n表示美味程度。
输出格式
第一行方案总数。
第二行至结束 10 10 10 个数表示每种配料所放的质量按字典序排列。
如果没有符合要求的方法就只要在第一行输出一个 0 0 0。
样例 #1
样例输入 #1
11样例输出 #1
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提示
对于 100 % 100\% 100% 的数据 n ≤ 5000 n \leq 5000 n≤5000。
#include iostream
#include cstring
#include algorithmusing namespace std;
const int N 20;int path[N];
int all_path[59055][N];
int n;
int res;void dfs(int x, int sum){if (sum n) return ; // 剪枝if (x 10){if (sum n){res ;for (int i 1; i 10; i ){all_path[res][i] path[i]; } }return;}for (int i 1; i 3; i ){path[x] i;dfs(x 1, sum i);path[x] 0;}}
int main(){scanf(%d, n);if (n 30 || n 10) puts(0);else{dfs(1, 0);printf(%d\n, res);for (int i 1; i res; i ){for (int j 1; j 10; j ){printf(%d , all_path[i][j]);}printf(\n);}}return 0;
}