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最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己 ...
随机推荐
- 长沙JavaEE培训机构哪家比较靠谱?Java培训的职业前景
长沙JavaEE培训机构哪家比较靠谱?可信度高? 全球信息化的时代已经到来,IT行业越来越受大众的欢迎,所以越来越多的人把注意力集中到IT职业教育培训.在软件开发领域,Java培训已经成为人们的首选, ...
- [leetcode-592-Fraction Addition and Subtraction]
Given a string representing an expression of fraction addition and subtraction, you need to return t ...
- 打开vmvare出现The VMware Authorization Service is not running。
win+r再输入cmd打开doc,输入services.msc打开服务,吧Vmware Authorization Service 更改为自动或者将其启动即可.
- easyui框架--基础篇(一)-->数据表格datagrid(php与mysql交互)
前 言 php easyui框架--本篇学习主要是 easyui中的datagrid(数据表格)框架. 本篇学习主要通过讲解一段代码加GIF图片学习datagrid(数据表格)中的一些常用属 ...
- Navigation Controller 创建方法
添加Navigation Controller的方法主要有两种: 第一种:主要是通过在storyboard中拖入Object library 中的Navigation Controller 第二种方法 ...
- Spring+SpringMVC+MyBatis深入学习及搭建(十六)——SpringMVC注解开发(高级篇)
转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/7085268.html 前面讲到:Spring+SpringMVC+MyBatis深入学习及搭建(十五)——S ...
- 改变图像,运用match方法判断
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>菜鸟 ...
- 【Vue】Vue的依赖追踪系统 ——搞懂methods watch和compute
从作用机制和性质上看待methods,watch和computed的关系 <他三个是啥子关系呢?> 首先要说,methods,watch和computed都是以函数为基础的,但各自却都不同 ...
- POJ 3126 math(BFS)
Prime Path Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21581 Accepted: 11986 Desc ...
- Java List Remove时要注意的细节
1.如果你是在遍历的时候去remove一个对象 for(int i = 0, length = list.size(); i<length; i++){} 这种遍历需要每次remove时,对i- ...