#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
struct Num{
int v, q;
}num[12];
int t, n;
int qty[12];
int cnt, j;
void Test(int p)
{
if (p == -1)
{
int sum = 0;
for (int i = 0; i < j; i++)
sum += qty[i]*num[i].v;
if (sum == t)
{
cnt = 1;
int q[12], i;
for (i = 0; i < j; i++) q[i] = qty[i];
int ss = 0;
for (i =j-1; i >=0; i--)
{
while (q[i]>0){
if (ss) printf("+");
ss=1;
printf("%d", num[i].v);
q[i]--;
}
}
printf("/n");
}
return ;
}
for (int q = num[p].q; q>=0; q--){
qty[p] = q;
Test(p-1);
}
}
int main()
{
int a[12];
while (scanf("%d",&t), t)
{
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d", &a[i]);
sort(a, a+n);
Num tmp={a[0], 1};
j = 0;
for (int i = 1; i < n; i++)
{
if (a[i] == a[i-1]) tmp.q++;
else
{
num[j++] = tmp;
tmp.v = a[i]; tmp.q = 1;
}
}
num[j++] = tmp;
printf("Sums of %d:/n", t);
cnt = 0;
Test(j-1);
if (cnt == 0) printf("NONE/n");
//cout<<endl;
}
}
相关推荐
[RK3399][Android7.1] 调试笔记 --- 编译GSL5680 touch提示错误
Platform: RK3399 OS: Android 7.1 Kernel: v4.4.83 现象: 之前在rk3288平台上使用过GSL5680的Touch,现在移植过来一直报如下错误: make[1]: `include/generated/vdso-offsets.h' is up to date. CHK include/generated/compi...
zoj1711
zoj1711
LAMMPS in文件详解:从零开始手把手教你配置金属分子动力学模拟
本文详细解析了LAMMPS in文件的配置方法,手把手教你完成金属分子动力学模拟的全流程。从软件环境准备、势函数选择,到使用Materials Studio构建模型、编写in文件进行能量最小化与系统弛豫,再到实施单轴拉伸生产模拟并提取应力应变数据,最后通过Python和OVITO进行结果分析与可视化,提供了完整的实战指南和常见问题排查技巧。
ZOJ-1711
DFS搜索。。不能重复出现相同式子的和
深入解读ES8388寄存器:从录音到播放,如何用代码控制这颗音频Codec
本文深入解析ES8388音频编解码器的寄存器设置,从录音到播放的完整控制流程。详细介绍了寄存器架构、录音通道配置、播放通道优化以及直通(Bypass)模式的高级应用,帮助开发者通过代码精准控制这颗高性能音频Codec,解决实际开发中的音质问题。
IMU自动校准论文与代码实现A Robust and Easy to Implement Method for IMU Calibration without External Equipments
PART1 摘要 低成本的惯性测量单元会受到系统误差的影响,系统误差由标度因子和轴偏差造成,这会降低位置和姿态估计的精度。 本文提出了一种无需任何外部设备的,鲁棒性强,易于实现的IMU校准方法。 该程序基于多放置方案,再估计传感器偏差的同时,为加速度和陀螺仪三轴的尺度和偏差系数。我们的方法只需要用手移动传感器,并将其放置在一组不同的静态位置(姿态)。 论文描述了一个鲁棒的快速校准协议,...
zoj 1711 Sum It Up //深搜
居然没超时 ... ps:index 是关键字么 ... #include #include #include #include using namespace std; int t,n,flag,ll; int a[14],vis[14]; char pr[1000][100]; //int f[15]={1,2,4,8,16,32,64,128,256,512,1024,2048,4096
模型预测控制(MPC)算法介绍
模型预测控制(Model Predictive Control,MPC)是一种先进的控制策略,广泛应用于工业过程控制、机器人控制、电力系统等领域。它基于系统的模型,通过滚动优化来预测系统未来的行为,并据此确定当前的最优控制输入。
ZOJ1711
题意:给出一个数n 和a1....ak 问
基于JeecgBoot 3.9.0 开源项目的企业管理平台
基于JeecgBoot 3.9.0 开源项目的企业管理平台
云原生监控:Prometheus+Grafana监控Nginx实战
在云原生环境中,应用的高可用性和性能优化至关重要。Nginx作为一款广泛使用的高性能Web服务器、反向代理服务器及电子邮件(IMAP/POP3)代理服务器,对其进行有效的监控能够及时发现潜在问题,保障服务的稳定运行。本文章的目的是详细介绍如何使用Prometheus和Grafana构建一套完整的监控系统来监控Nginx,范围涵盖从环境搭建、数据采集、存储到可视化展示的整个流程。
zoj1711 dfs搜索+去重
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1711 思路;dfs搜索,把所有可能的情况存下来,重复的标记掉,输出结果 #include #include using namespace std; const int N=5000; int t,cnt,p,flag,sum,n,ans[N][13],iso
RK3399驱动开发 | 19 - 阿美林7寸mipi屏幕调试(基于linux4.4.194内核)
NULL
zoj1711-Sum It Up
zoj1711-Sum It Up 题链:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1711
复分析 阿尔福斯(Ahlfors) 第三版答案 英文
答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案
Probability and Statistics - 4th edition
Probability and Statistics - 4th edition
ZOJ 1711 Sum It Up
/*Sum It Up--------------------------------------------------------------------------------Time Limit: 1 Second Memory Limit: 32768 KB ------------------------------------------------------
大中型超市收银系统(可直接运行)
光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开
ZOJ 1711 Sum It Up(DFS)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=711 Given a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For exa...
怀旧版电脑GBC模拟器
再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。
ZOJ1711 POJ1564 Sum It Up,DFS+输出排序+去重复
这题一看上去就知道要用DFS了,但是里面有个条件,输出必须是按字典序排序的,而且还要去除重复项。看到这里一般都会想尽很多办法的,不过我就直接用multiset和set。multiset运行容器中的元素重复,这样可以记录所有的组合;而set是不允许容器中的元素重复的,这样就可以把结
zoj 1711 || poj 1564 Sum It Up(DFS~~~去重~)
<br />给你一个数字n和一系列数字,不递减的,找出加和等于所给的n的方案。<br /> <br />要求输出也是按递减的,逆字典序。。。<br /> <br />先用DFS找出所有方案,存下,然后去重即可。<br /> <br />开始用的memcmp死活不对,好吧,我用笨方法,一个一个比较,重复的标记掉,剩下的就是需要输出的。<br /> <br />费了挺长时间的,郁闷。下次不能懒了!没有好办法之前,麻烦的就是最好的。。。<br /> <br />#include <stdio.h> #inclu
HDU1258 POJ1564 UVA574 UVALive5319 ZOJ1711 Sum It Up【DFS】
Sum It Up Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7926 Accepted: 4068 Description Given a specified total t and a list of n integers, find all distinct s...
ZOJ1711-sum it up(DFS+去重)
Sum It Up Time Limit: 2 Seconds Memory Limit: 65536 KB Given a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t =
ZOJ(1711)Sum It Up (DFS+剪枝+去重复)
#include <iostream> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <math.h> #include <fstream> #include <v...
poj 1564 && zoj 1711 Sum It Up (dfs)
http://poj.org/problem?id=1564http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1711 简单深搜,主要是这一句 if(!vis[i]&&data[i]<=sum&&(data[i]!=data[i-1]||i==pos))。 确保两个连续的相同的数只有...
1056



被折叠的 条评论
为什么被折叠?



