hdu--1258--Sum It Up(Map水过)
Sum It Up
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6581 Accepted Submission(s): 3451
/*
Name: hdu--1258--Sum It Up
Copyright: ©2017 日天大帝
Author: 日天大帝
Date: 29/04/17 18:48
Description: dfs,C++map水过
*/
#include<iostream>
#include<cstring>
#include<map>
using namespace std;
void dfs(int,int,map<int,int,greater<int>>::iterator it);
;
int res[MAX];
int n,t,flag;
map<int,int,greater<int>> mymap;
int main(){
ios::sync_with_stdio(false);
while(cin>>n>>t,n||t){
mymap.clear();
flag = ;
memset(res,,sizeof(res));
; i<t; ++i){
int a;cin>>a;
mymap[a]++;
}
cout<<"Sums of "<<n<<":"<<endl;
dfs(,,mymap.begin());
)cout<<"NONE"<<endl;
}
;
}
void dfs(int sum,int ct,map<int,int,greater<int>>::iterator iter){
if(sum == n){
flag = ;
cout<<res[];
; i<ct; ++i){
cout<<"+"<<res[i];
}
cout<<endl;
}
for(auto it=iter; it!=mymap.end(); ++it){
)continue;
; i--){
if(sum+(i*it->first) > n)continue;
; k<i; ++k){
res[ct + k] = it->first;
}
auto ipoint = it;
dfs(sum+(i*it->first),ct+i,++ipoint);
}
}
}
hdu--1258--Sum It Up(Map水过)的更多相关文章
- HDOJ(HDU).1258 Sum It Up (DFS)
HDOJ(HDU).1258 Sum It Up (DFS) [从零开始DFS(6)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双 ...
- HDU 1258 Sum It Up(dfs 巧妙去重)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1258 Sum It Up Time Limit: 2000/1000 MS (Java/Others) ...
- hdu 1258 Sum It Up (dfs+路径记录)
pid=1258">Sum It Up Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- hdu 1258 Sum It Up(dfs+去重)
题目大意: 给你一个总和(total)和一列(list)整数,共n个整数,要求用这些整数相加,使相加的结果等于total,找出所有不相同的拼凑方法. 例如,total = 4,n = 6,list = ...
- HDU 1258 Sum It Up(DFS)
题目链接 Problem Description Given a specified total t and a list of n integers, find all distinct sums ...
- HDU 1258 Sum It Up
Sum It Up Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total S ...
- (step4.3.4)hdu 1258(Sum It Up——DFS)
题目大意:输入t,n,接下来有n个数组成的一个序列.输出总和为t的子序列 解题思路:DFS 代码如下(有详细的注释): #include <iostream> #include <a ...
- HDU 4432 Sum of divisors (水题,进制转换)
题意:给定 n,m,把 n 的所有因数转 m 进制,再把各都平方,求和. 析:按它的要求做就好,注意的是,是因数,不可能有重复的...比如4的因数只有一个2,还有就是输出10进制以上的,要用AB.. ...
- HDU 1258 Sum It Up (DFS)
Sum It Up Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total S ...
- HDOJ/HDU 1251 统计难题(字典树啥的~Map水过)
Problem Description Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己 ...
随机推荐
- Mac, Linux中配置Latex中文字体
对于中文的latex文档,在Linux下一般可以使用系统自带的开源字体:文泉驿(WenQuanYi)来实现,即如下的最小例子,通过xelatex命令来编译即可生成中文文档. \documentclas ...
- 如何使用Node.js编写命令工具——以vue-cli为例
vue-cli全局安装之后,提供了vue命令和vue init.vue list.vue build三个子命令,通过命令可以搭建基于vue.js的脚手架项目.本文简单介绍一下这些命令是如何实现的. v ...
- ci框架中输出sql语句
- jquery滚动条事件
<!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8& ...
- 遇到ANDROID “call to opengl es api with no current context”错误
延迟线程执行 Timer timer=new Timer();//实例化Timer类 timer.schedule(new TimerTask(){ public void run(){ buyed( ...
- 在vs2010中显示代码的行数
1.打开VS2010,然后"工具" → "选项" 2.在选项页面,点击"文本编辑器"→"所有语言",在显示里将[行号]选 ...
- Angular路由(三)
AngularJs ng-route路由详解 其实主要是$routeProvider搭配ng-view实现. ng-view的实现原理,基本就是根据路由的切换,动态编译html模板. 前提 首先必须在 ...
- Vysor破解助手for Linux/macOS/Windows
Vysor更新到1.7.8后,之前的破解工具又失效了,但破解的方法依然可用.在更新破解工具的过程中,Vysor又出了1.7.9版本,主要是对Android O做了处理.更新后的破解工具支持1.6.6~ ...
- IT行业歧视40岁以上人群为找工作还要谎报年龄[转]
IT行业歧视40岁以上人群为找工作还要谎报年龄(这样不好) http://www.aliyun.com/zixun/content/2_6_616161.html [赛迪网讯]4月5日消息,许多40多 ...
- 为Dynamics 365写一个简单程序实现解决方案一键迁移
关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复258或者20170627可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong. ...