ZCMU-1133


emm就直接看的前辈的了。
唉
#include <stdio.h>
#include <string.h>
#include <algorithm>
//我不成熟的想法是两成遍历
//但感觉会时间超限,但没有先想到深度搜索
using namespace std;
int n,t;
int num[101];
//存放输入情况
int r[101];
//记录可能情况
bool flag;
void dfs(int len,int k,int last)
{
int result;
if(last==0){
flag=false;
for(int i=0;i<len;i++)
if(i==0)printf("%d",r[i]);
else printf("+%d",r[i]);
printf("\n");
return ;
}
for(int i=k;i<n;i++){
if(i==k||num[i]!=num[i-1]&&last-num[i]>=0)// 去除重复的操作
{
//这里的i==k或者后面情况是
//为了保证遇到前后相同时,自身不会被重用
//并且还能使用后面的情况
r[len]=num[i];
dfs(len+1,i+1,last-num[i]);
}
}
}
int main()
{
while(scanf("%d%d",&t,&n)!=EOF)
{
memset(r,0,sizeof(r));
memset(num,0,sizeof(num));
if(t==n&&n==0)break;
flag=true;
for(int i=0;i<n;i++)
scanf("%d",&num[i]);
printf("Sums of %d:\n", t);
dfs(0,0,t);
if(flag)printf("NONE\n");
}
return 0;
}
ZCMU-1133的更多相关文章
- ApexSql Log 2014.04.1133破解版&补丁
已上传最新的2016版本,请移步: http://www.cnblogs.com/gsyifan/p/ApexSql_Log_2016_Crack.html 状态不好,鬼使补差的跑到服务器上updat ...
- codevs 1133 表达式的值
1133 表达式的值 2011年NOIP全国联赛普及组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 查看运行结果 题目描述 Descript ...
- bzoj 1133: [POI2009]Kon dp
1133: [POI2009]Kon Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 242 Solved: 81[Submit][Status][D ...
- 【HDU 1133】 Buy the Ticket (卡特兰数)
Buy the Ticket Problem Description The "Harry Potter and the Goblet of Fire" will be on sh ...
- Buy the Ticket HDU 1133 递推+大数
题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=1133 题目大意: 有m+n个人去买电影票,每张电影票50元, m个人是只有50元一张的, n个人 ...
- Sicily 1133. SPAM
题目地址:1133. SPAM 思路: 题目意思是说在‘@’的前后出现题目给定的合法字符或者不连续出现‘.’字符的话,这个就是合理的输出. 那么以@为中心,向前,向后扫描,当扫描到不符合字符时,记录此 ...
- ***1133. Fibonacci Sequence(斐波那契数列,二分,数论)
1133. Fibonacci Sequence Time limit: 1.0 secondMemory limit: 64 MB is an infinite sequence of intege ...
- 1133: 零起点学算法40——多组测试数据(a+b)II
1133: 零起点学算法40--多组测试数据(a+b)II Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitte ...
- Buy the Ticket HDU 1133
传送门 [http://acm.hdu.edu.cn/showproblem.php?pid=1133] 题目描述和分析 代码 #include<iostream> #include< ...
- MySQL.ERROR 1133 (42000): Can't find any matching row in the user table
ERROR 1133 (42000): Can't find any matching row in the user table 今天在执行 grant all privileges on cac ...
随机推荐
- C#阿里境外服务器部署企业邮箱发邮件代码
static string accountName = "发件人邮箱"; static string password = "发件人邮箱密码"; static ...
- Angular 18+ 高级教程 – Routing 路由 (原理篇)
修改中... 前言 Angular 是 Single Page Application (SPA) 单页面应用,所谓的单页面是站在服务端的角度看,不管游览器请求什么路径,一律返回 index.html ...
- RSA 对称加密,对称解密----公钥私钥加密解密过程
RSA 对称加密,对称解密----公钥私钥加密解密过程(Java) 公司说不能传铭文密码,所以只能加密,再解密:麻烦事,其实这在需求文档没有,开发时间点也没有,浪费了了一上午的时间,还占用了公司给的开 ...
- C++ 指针基础
指针 指针具有强大的能力,其本质是协助程序员完成内存的直接操作 指针: 特定类型数据在内存中的存储地址,即内存地址 指针只是一个逻辑概念,其实际应用是:指针变量 语法 * 符号有两种含义: 声明时:* ...
- OxyPlot公共属性一览
一.PlotModel 1.构造函数中设置的属性 public PlotModel() { this.Axes = new ElementCollection(this); //坐标轴集合; this ...
- 采集数据产品描述有超链接///设置免运费后,达到免送标准,其他运费不显示///给产品详情页面的图片点击放大是个模态窗///在shop页面有重复的产品展示,去重
//产品描述有超链接,去掉 function remove_product_hyperlinks($content) { if (is_product()) { // 确保只在产品页面上应用 $con ...
- LeetCode 1000. Minimum Cost to Merge Stones (区间 DP)
根据寒神题解 https://leetcode.com/problems/minimum-cost-to-merge-stones/discuss/247567/JavaC%2B%2BPython-D ...
- 简单粗暴的实现 Blazor Server 登录鉴权
既然是简单粗暴,那么就不用关心诸如 IDentityServer4,OAuth 之类的组件,也不使用 AuthenticationStateProvider.IAuthService, razor 页 ...
- 09-react的组件传值 props
// 组件传值 props 接收传递过来的数据 import ReactDom from "react-dom" import { Component } from "r ...
- PHP实现断点续传
解释 业务上要求对资源文件进行加密,遂实现通过php接口调用,修改header头,传输流的方式. 测试中,在苹果手机上,如果文件过大(大概10M以上),会主动调用多次接口.此时如果不使用断点续传的方式 ...