P2089 烤鸡

题目描述

猪猪 Hanke 特别喜欢吃烤鸡(本是同畜牲,相煎何太急!)Hanke 吃鸡很特别,为什么特别呢?因为他有 1010 种配料(芥末、孜然等),每种配料可以放 11 到 33 克,任意烤鸡的美味程度为所有配料质量之和。

现在, Hanke 想要知道,如果给你一个美味程度 nn ,请输出这 1010 种配料的所有搭配方案。

输入格式

一个正整数 nn,表示美味程度。

输出格式

第一行,方案总数。

第二行至结束,1010 个数,表示每种配料所放的质量,按字典序排列。

如果没有符合要求的方法,就只要在第一行输出一个 00。

输入输出样例

输入 #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% 的数据,n \leq 5000n≤5000。

#include <iostream>
using namespace std;
int main(){
	int n,sum=0;
	cin>>n;
	for(int a1=1;a1<=3;a1++){
		for(int a2=1;a2<=3;a2++){
			for(int a3=1;a3<=3;a3++){
				for(int a4=1;a4<=3;a4++){
					for(int a5=1;a5<=3;a5++){
						for(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){
												sum++;
											}
										}	
									}	
								}	
							}	
						}	
					}	
				}
			}	
		}	
	}
	cout<<sum<<endl;
	for(int a1=1;a1<=3;a1++){
		for(int a2=1;a2<=3;a2++){
			for(int a3=1;a3<=3;a3++){
				for(int a4=1;a4<=3;a4++){
					for(int a5=1;a5<=3;a5++){
						for(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){
												cout<<a1<<" "<<a2<<" "<<a3<<" "<<a4<<" "<<a5<<" "<<a6<<" "<<a7<<" "<<a8<<" "<<a9<<" "<<a10<<endl;
											}
										}	
									}	
								}	
							}	
						}	
					}	
				}
			}	
		}	
	}
    return 0;
}




十分暴力!!!!!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值