E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
hdu1171
HDU1171
0-1背包问题
题意和思路:给出物品价值和数量,数组存储每个物品的价值,重复的分别存储,转化为0-1背包问题,要使得a,b分得的价值最接近且a不小于b,总价值的一半就是背包的容量。代码如下:#include#include#include#include#includeusingnamespacestd;intmain(){intn,v,c;intdp[300000],p[5005];while(cin>>n&&
山月不知_心底事
·
2020-09-17 12:39
【
HDU1171
】母函数
1.题目链接。题意就是给你一些物品,这些物品有价值和数量,将他们分成两堆,尽可能的均分(二者之差尽可能的小)。前边我们分析过了,这可以使用背包解决,但是我们使用母函数也是可以解决的,本质上来说二者的区别不是很大,都是再一堆物品中选出一些合适的东西来,都是组合的思想。我们知道,再母函数的代码里面,我们有一层的循环是这样子写的:for(i=1;i#include#includeusingnamespa
MatrixYg
·
2020-07-30 04:32
组合数学
hdu1171
(母函数或多重背包)
题意:把物品分成两份,使得价值最接近可以用背包,或者是母函数来解,母函数(1+x^v+x^2v+.....+x^num*v)(1+x^v+x^2v+.....+x^num*v)(1+x^v+x^2v+.....+x^num*v)其中指数为价值,每一项的数目为(该物品数+1)个代码如下:#include#include#include#include#include#include#include#
slmady
·
2020-07-30 01:27
acm之母函数
HDU1171
Big Event in HDU (母函数)
BigEventinHDUTimeLimit:10000/5000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):40542AcceptedSubmission(s):13941ProblemDescriptionNowadays,weallknowthatComputerCollegeisthebigg
TooSIMple_
·
2020-07-29 19:26
ACM
hdu1171
二进制优化背包问题
BigEventinHDUProblemDescriptionNowadays,weallknowthatComputerCollegeisthebiggestdepartmentinHDU.But,maybeyoudon’tknowthatComputerCollegehadeverbeensplitintoComputerCollegeandSoftwareCollegein2002.Thes
zt_1995
·
2020-07-29 03:58
动态规划
hdu
hdu1171
http://acm.hdu.edu.cn/showproblem.php?pid=1171题意:有n样物品,每样物品价值是v,件数是m。尽量把这些物品分成两堆使得两边总价值最接近。输出分得的两堆各自的价值。思路:记录总价值sum,然后把sum/2当做背包容积小提示:输入截止是n#include#includeusingnamespacestd;intmax(intx,inty){if(x>y)r
whiskey_wei
·
2020-07-28 23:27
dp-背包
HDU1171
——01背包入门基础题
题目:Nowadays,weallknowthatComputerCollegeisthebiggestdepartmentinHDU.But,maybeyoudon'tknowthatComputerCollegehadeverbeensplitintoComputerCollegeandSoftwareCollegein2002.Thesplittingisabsolutelyabigeven
booooooty
·
2020-07-28 08:38
杭电1171(
HDU1171
)
题意:现在我们都知道电脑学院是HDU最大的部门。但是,也许你不知道2002年计算机学院曾经被分解成电脑学院和软件学院。分裂绝对是HDU中的一件大事!同时这也是麻烦的事情。所有的设施必须放在一半。首先,对所有设施进行评估,如果两个设施具有相同的价值,则认为两个设施是相同的。假设有N(0#include#includeusingnamespacestd;longlongc1[250010],c2[25
qq_37751662
·
2020-07-28 07:37
HDU1171
Big Event in HDU 01背包 母函数 TWT Tokyo Olympic 2COMBO-1 未完待续
BigEventinHDUTimeLimit:10000/5000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):36353AcceptedSubmission(s):12631ProblemDescriptionNowadays,weallknowthatComputerCollegeisthebigg
kyoma
·
2020-07-28 01:21
01背包
待补完
hdu1171
(单调队列优化多重背包)
ProblemDescriptionNowadays,weallknowthatComputerCollegeisthebiggestdepartmentinHDU.But,maybeyoudon’tknowthatComputerCollegehadeverbeensplitintoComputerCollegeandSoftwareCollegein2002.Thesplittingisabs
zjy2015302395
·
2020-07-15 12:15
acm
基本算法
hdu1171
(多重背包)
BigEventinHDUTimeLimit:10000/5000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):18647AcceptedSubmission(s):6522ProblemDescriptionNowadays,weallknowthatComputerCollegeisthebigge
晓风残月xj
·
2020-07-15 10:47
动态规划-背包-多重背包
hdu1171
01背包
BigEventinHDUTimeLimit:10000/5000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):36600AcceptedSubmission(s):12715ProblemDescriptionNowadays,weallknowthatComputerCollegeisthebigg
sumword_
·
2020-07-14 23:39
动态规划
hdu1171
(01背包问题)
将总值分为2就是01背包问题了可以作为01背包问题模板////main.cpp//6.5////CreatedbyMr.Xueon17/7/17.//Copyright©2017年Mr.Xue.Allrightsreserved.//#include#include#include#includeusingnamespacestd;intdp[300000],l[5005];intmax(inta
Polya_Xue
·
2020-07-14 17:15
01背包问题
HDU1171
一维01背包DP
BigEventinHDUTimeLimit:10000/5000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):33452AcceptedSubmission(s):11642ProblemDescriptionNowadays,weallknowthatComputerCollegeisthebigg
qdbszsj
·
2020-07-14 16:12
刷题
HDU1171
(01背包)
BigEventinHDUTimeLimit:10000/5000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):33311AcceptedSubmission(s):11596ProblemDescriptionNowadays,weallknowthatComputerCollegeisthebigg
MrBlankIsAwesome
·
2020-07-14 15:15
DP
HDU1171
:Big Event in HDU(01背包)
ProblemDescriptionNowadays,weallknowthatComputerCollegeisthebiggestdepartmentinHDU.But,maybeyoudon'tknowthatComputerCollegehadeverbeensplitintoComputerCollegeandSoftwareCollegein2002.Thesplittingisabs
键盘上的舞者
·
2020-07-14 13:40
背包
hdu1171
Big Event in HDU --01背包
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1171一:原题内容ProblemDescriptionNowadays,weallknowthatComputerCollegeisthebiggestdepartmentinHDU.But,maybeyoudon'tknowthatComputerCollegehadeverbeensplitinto
LaoJiu_
·
2020-07-14 05:30
【动态规划】--背包问题
HDU1171
单调队列优化多重背包O(VN)
BigEventinHDUTimeLimit:10000/5000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):6218AcceptedSubmission(s):1996ProblemDescriptionNowadays,weallknowthatComputerCollegeisthebigges
ACM_DavidCN
·
2020-07-14 03:30
解题报告
动态规划DP
数据结构----单调队列
[01背包]
hdu1171
题目有一个数组,要把他们分成两堆使其差值最小,求两堆的val思路呜呜呜居然是01背包,求dp[sum/2]就好了代码#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#inclu
kosf_
·
2020-07-14 01:14
生成函数(背包)-
HDU1171
https://vjudge.net/contest/181055#problem/C生成函数的解法要注意最后的判断,生成函数的用时更长。背包是标准解法。#include#include#include#include#include#include#include#include#definelllonglongusingnamespacestd;constintmaxn=1e5+10;cons
d12155214552
·
2017-08-23 14:26
数学补充
HDU1171
- Big Event in HDU 动态规划之多重背包
1.题目叙述:BigEventinHDUTimeLimit:10000/5000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):38791AcceptedSubmission(s):13417ProblemDescriptionNowadays,weallknowthatComputerCollegeis
寒江雪里独钓着的蓑笠翁
·
2017-03-02 23:54
动态规划(DP)
思维
hdu1171
Big Event in HDU(DP)
题意:给出每个物体的价值和物体的数量,如何分使得A,B所得价值最接近并且A的价值不能小于B思路:将总和平分后,就是一道01背包题了#include #include #include usingnamespacestd; intval[5005]; intdp[255555]; intmain() { intn,i,j,a,b,l,sum; while(~scanf("%d",&n),n>0)
qq_21057881
·
2016-05-12 17:00
hdu1171
Big Event in HDU
BigEventinHDUTimeLimit:10000/5000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):34053 AcceptedSubmission(s):11816ProblemDescriptionNowadays,weallknowthatComputerCollegei
qq_33406883
·
2016-05-11 12:00
hdu1171
Big Event in HDU --01背包
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1171一:原题内容ProblemDescriptionNowadays,weallknowthatComputerCollegeisthebiggestdepartmentinHDU.But,maybeyoudon'tknowthatComputerCollegehadeverbeensplitinto
LaoJiu_
·
2016-04-21 12:00
HDU1171
一维01背包DP
BigEventinHDUTimeLimit:10000/5000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):33452 AcceptedSubmission(s):11642ProblemDescriptionNowadays,weallknowthatComputerCollegeisthe
qdbszsj
·
2016-04-18 14:00
HDU1171
(01背包)
BigEventinHDUTimeLimit:10000/5000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):33311AcceptedSubmission(s):11596ProblemDescriptionNowadays,weallknowthatComputerCollegeisthebigg
mrlry
·
2016-04-13 21:00
(模版测试题
hdu1171
)
kmp是数据结构里面关于字符串很重要的内容关于kmp,网上有很多资料,但是有的人看了看懂了,有的看了还是看不明白所以我自己还是要自己整理一下。关于kmp求next数组,这是最难的,很难理解,尤其是那一句k=next[k],真的是让人费解首先,kmp高效的原因是因为,进行了预处理,然后匹配时主串不回溯,使得kmp效率达到了O(n+m),比起普通的暴力匹配高效了不少。首先我们来分析一下get_next
mymilkbottles
·
2016-03-15 21:00
hdu1171
链接:点击打开链接题意:给出每个物品的价值和数量,如何分配使得A,B所得价值最接近并且A的价值不能小于B代码:#include #include #include #include usingnamespacestd; intv[10005],w[10005],dp[500005]; intmain(){ intn,i,j,k,num,tmp,sum; while(scanf("%
stay_accept
·
2016-02-23 22:00
Big Event in HDU[
HDU1171
]
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18273 Accepted Submission(s): 6403
·
2015-11-13 22:18
event
多重背包的入门题目
HDU1171
,2191,2844.
首先,什么叫多重背包呢? 大概意思就是:一个背包有V总容量,有N种物品,其价值分别为Val1,Val2……,Val3,体积对应的是Vol1,Vol2,……,Vol3,件数对应Num1,Num2……,Num3 求背包至多装满的最大总价值。 其实,首先可以当作01背包来做,这时候复杂度就是O(V*sum(Num[i])); 简单代码来说就是 for(int i
·
2015-11-11 08:18
HDU
hdu1171
Big Event in HDU 01-背包
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1171 Problem Description Nowadays, we all know that Computer College is the biggest department in HDU. But,
·
2015-11-11 03:12
event
HDU1171
:Big Event in HDU(多重背包分析)
通过分析,要使A>=B并且差值最小。所以只要使sum/2的容量下,B最大就Ok了 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<string> using namespace std; #defin
·
2015-11-10 23:28
event
HDU1171
(背包)
题意:求把总价值分为两个数,使这两个数接近相等,而且这两个数必须由所有设备中的其中几种设备价值构成,并先输出比较大的数,再输出另一个数。 解题思路:DP算法,背包问题,求法是先求出总价值sum,再用dp[]求sum/2最多能放多少价值!即可以求出其中一个数了,另一个就是sum-dp[sum/2]了……状态:f[j]:表示软件学院取得容量为j时能获得的最大值,j<=sum/2; 状态转移:f
·
2015-11-02 11:08
HDU
hdu 1171 Big Event in HDU(多重背包+二进制优化)
题目链接:
hdu1171
思路:将多重背包转为成完全背包和01背包问题,转化为01背包是用二进制思想,即件数amount用分解成若干个件数的集合,这里面数字可以组合成任意小于等于amount的件数
·
2015-10-30 13:25
event
均分背包
HDU1171
1 #include <cstring> 2 #include <iostream> 3 #include <algorithm> 4 5 using namespace std; 6 7 long long dp[250010]; 8 int v[5500][2]; 9 10 int main() 11 { 12
·
2015-10-30 10:30
HDU
母函数相关题目
题目:hdu1085、
hdu1171
、hdu1398、hdu2079、hdu2082、hdu2110、hdu215
wust_ZJX
·
2015-03-13 22:00
hdu1171
Big Event in HDU (01背包变形)
分析:题目要求分给俩个学院的设备价值 尽可能相等,第一个学院获得的设备价值>=第二个学院。对设备总价值的一半 作为01背包的体积。题目:http://acm.hdu.edu.cn/showproblem.php?pid=1171#include #include #include #include usingnamespacestd; intmain(){ intn,v,m; intval[501
f1024042400
·
2014-12-26 10:00
HDU 1171 Big Event in HDU(01背包)
题目地址:
HDU1171
还是水题。。普通的01背包。注意数组要开大点啊。。。。
u013013910
·
2014-08-27 21:00
编程
算法
C语言
ACM
01背包
HDU1171
Big Event in HDU 【母函数】
BigEventinHDUTimeLimit:10000/5000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):22835 AcceptedSubmission(s):8018ProblemDescriptionNowadays,weallknowthatComputerCollegeis
u012846486
·
2014-07-26 14:00
hdu1171
hdu1171
完全背包 两种解法 多重背包
BigEventinHDUTimeLimit:10000/5000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):21202 AcceptedSubmission(s):7460ProblemDescriptionNowadays,weallknowthatComputerCollegeis
u011455899
·
2014-04-02 17:00
hdu1171
转化01背包,组合
题意就是给你一些有价值的物品,你要把它分成尽量相同的两份。#include #include #include usingnamespacestd; intmain() { intt; while(cin>>t) { if(t>a>>m; for(inti=len;i=val[i];j--) { inttem=val[i]+cost[j-val[i]]; if(tem>cost[j]) cost
guodongxiaren
·
2014-03-30 20:00
ACM
HDU
hdu1171
hdu 1059 Dividing(优化的多重背包 可达可不达)
pid=1059题意:有六种marbles,第i种marbles的价值为i,数量为输入的num[i],两个人想按这些marbles的总价值平分,问他们是否能够平分成功.思路:和
hdu1171
http:
u013081425
·
2014-02-24 19:00
dp
hdu1171
(多重背包)
BigEventinHDUTimeLimit:10000/5000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):18647 AcceptedSubmission(s):6522ProblemDescriptionNowadays,weallknowthatComputerCollegeis
xj2419174554
·
2013-08-07 11:00
动态规划
HDU1171
:Big Event in HDU(多重背包)
ProblemDescriptionNowadays,weallknowthatComputerCollegeisthebiggestdepartmentinHDU.But,maybeyoudon'tknowthatComputerCollegehadeverbeensplitintoComputerCollegeandSoftwareCollegein2002.Thesplittingisabs
libin56842
·
2013-07-21 11:00
HDU
背包
HDU1171
:Big Event in HDU(01背包)
ProblemDescriptionNowadays,weallknowthatComputerCollegeisthebiggestdepartmentinHDU.But,maybeyoudon'tknowthatComputerCollegehadeverbeensplitintoComputerCollegeandSoftwareCollegein2002.Thesplittingisabs
libin56842
·
2013-06-05 22:00
ACM
HDU
杭电
01背包
hdu1171
之Big Event in HDU
ProblemDescription Nowadays,weallknowthatComputerCollegeisthebiggestdepartmentinHDU.But,maybeyoudon'tknowthatComputerCollegehadeverbeensplitintoComputerCollegeandSoftwareCollegein2002.Thesplittingis
xingyeyongheng
·
2012-12-05 22:00
hdu1171
http://acm.hdu.edu.cn/showproblem.php?pid=1171
//给你每中物品的价值和该物品的数量让你尽量把它们的总价值平均分配。 //注意细节用母函数容易超时注意stepsumMoney以及value*fac个代表的含义step代表前一个数列式子的个数sumMoney最大的指数value*fac当前总价值 #include #include #definemax250003 intc1[max],c2[max]; intmain() { intN; int
wahaha1_
·
2012-11-07 16:00
HDU1171
Big Event in HDU,母函数,终极模板
也是母函数水题。。。和上一题不一样,这一题给定的是各个元素价值和数目。同时对母函数的代码模板进行了简化。/******************************************************************************* #Author:NeoFung #Email:
[email protected]
#Lastmodified:2012-06-261
neofung
·
2012-06-26 19:00
email
HDU1171
Big Event in HDU
//这一题是看能够组合出哪些值,这些值距离sum/2最近的为最优的解 #include #include usingnamespacestd; intc1[250005]; intc2[250005]; intn,sum; structNode{ intval; intcount; }; Nodend[55]; intmain(){ while(scanf("%d",&n)&&n>0){ s
chen895281773
·
2012-05-16 21:00
c
ini
hdu1171
/*分析: 母函数。 先求出所有物品的总价值total,令aim=total/2,对0~aim进行母函数就行了。只要注意,每次遍历k的时候,k++的次数不大于相应物品的数量,就不会超时。 优化注意(代码行39的c2赋值):c的范围是13万,综合考虑,将0~aim的c逐个赋值为零,要比用memset将整个c赋值为零更快。 优化结果:1078MS变656MS。
Ice_Crazy
·
2012-05-07 18:00
上一页
1
2
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他