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最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己 ...
随机推荐
- 总结一下最近用过的phpcms语法
到目前为止用到过的phpcms语法: 1.取栏目名称: {category[$catid][catname]} 2.取栏目地址: {category[14][url]} 3.取一级栏目: {pc:co ...
- Gist - ES6 Iterator
Introduction Iterator is one of the most common design modes in daily development. Let's explore the ...
- php获取二维数组中某一列的值集合
$result //二维数组$uid_list = array_column($result, 'uid');
- php中有关合并某一字段键值相同的数组合并
<?php function combine($array,$start,$key,$newkey){ static $new; //静态变量 foreach($array as $k=> ...
- 关于ZendStudio 10.5的破解
一. 下载ZendStudio 10.5 首先下载ZendStudio 10.5 我使用的是mac版 下载地址是: http://downloads.zend.com/studio-eclipse/1 ...
- 13.localStorage和sessionStorage的区别
HTMl5的sessionStorage和localStorage html5中的Web Storage包括了两种存储方式:sessionStorage和localStorage. sessionSt ...
- (转载)配置tomcat支持jython
工作需要,特记录下配置tomcat支持jython开发的过程.参考链接:@http://blog.itpub.net/13186779/viewspace-201861/ *环境在win7下搭建,jd ...
- Tomcat集群搭建
关于如何搭建Tomcat集群网上还是能搜到很多相关的教程,这里结合我自己在实际应用中的操作做下备忘. 案例说明: 这里以在本机部署的2个tomcat来做集群.当然,tomcat集群可以是分布式的,而差 ...
- HDU 1051 Wooden Sticks 贪心||DP
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- Spring MVC 基本注解
1. Spring MVC 常用到的注解: @Controller @RequestMapping @RequestParam @RequestHeader @ModelAttribute @Path ...