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 ...
随机推荐
- sql日期创建
TRUNCATE TABLE SYS_DATEINFO declare @i int set @i=-30000 WHILE @i<1000000 BEGIN INSERT INTO SYS_D ...
- 掌握 C++17:结构化绑定与拷贝消除的妙用
C++17 特性示例 1. 结构化绑定(Structured Binding) 结构化绑定允许你用一个对象的元素或成员同时实例化多个实体. 结构化绑定允许你在声明变量的同时解构一个复合类型的数据结构( ...
- Angular 18+ 高级教程 – Angular 的局限和 Github Issues
前言 Angular 绝对有很多缺陷,Issue 非常多,workaround 非常多. 我以前至少有 subscribe 超过 20 个 Issues,几年都没有 right way 处理的. An ...
- CSS – Counters
介绍 counter 有点像 JS 的 for loop index. 最常用到的地方就是做 ol > li. 参考: W3Schools – CSS Counters 默认 ol > l ...
- SpringBoot——项目快速启动
SpringBoot项目快速启动 对SpringBoot项目打包(执行Maven构建指令package) 执行后会生成对应的项目 jar包,在文件夹找到该文件 在对应文件夹下即可执行 j ...
- 使用dynamic debug帮助调试
你一定在kernel source code中看过很多pr_debug()/dev_dbg()/print_hex_dump_debug()吧,这些debug语句提供更多的信息帮助我们了解内核运行流程 ...
- Android复习(四)权限—>请求应用权限
每款 Android 应用都在访问受限的沙盒中运行.如果应用需要使用其自己的沙盒外的资源或信息,则必须请求相应权限. 要声明您的应用需要某项权限,您可以在应用清单中列出该权限,然后在运行时请求用户批准 ...
- python中利用变量解压列表、元组、字符串、字典、文件对象、迭代器和生成器等序列
一.如果知道序列中元素的个数,可以直接进行变量赋值. coords = (102, 40) lon, lat = coords print(lon) print(lat) text = "n ...
- springboot 启动慢分析
JVM参数设置 1. 生成GC日志并网站在线分析 生成gc日志命令 -Xloggc:./gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps 在线分析网站 ...
- Rsync 秒杀一切备份工具,你能手动屏蔽某些目录吗?
引言 Rsync 是一种快速且通用的命令行实用程序,可通过远程shell在两个位置之间同步文件和文件夹. 使用 Rsync,可以镜像数据,创建增量备份,并在系统之间复制文件.复制数据时,你可能要根据文 ...