
动态规划(dp)
文章平均质量分 69
algzjh
这个作者很懒,什么都没留下…
展开
-
2018上海大都会赛J-Beautiful Numbers
模运算比较慢#include<bits/stdc++.h>using namespace std;typedef long long LL;int bit[20];LL dp[20][105][105];int gcd(int a,int b) {return b==0?a:gcd(b,a%b);}int lcm(int a,int b) {return a/gc...原创 2018-08-06 10:16:23 · 340 阅读 · 0 评论 -
COJ1980-不堪重负的树
1980: 不堪重负的树Submit Page Summary Time Limit: 1 Sec Memory Limit: 128 Mb Submitted: 21 Solved: 7 Description 小X非常喜欢树,然后他生成了一个大森林给自己玩。 玩着玩着,小X陷入了沉思。一棵树由N个节点组成,编号为i的节点有一个价值Wi。 假设从树根出原创 2017-08-12 14:18:29 · 827 阅读 · 0 评论 -
HDU1074-Doing Homework
Doing HomeworkTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9938 Accepted Submission(s): 4764Problem Description Ignatius has just come b原创 2017-08-18 18:28:07 · 476 阅读 · 0 评论 -
2017湖南多校第十三场-COJ1963-Feed the rabbit
Feed the rabbitDescription There are n holes in a line,the distance between the hole labeled i and i+1 is di。There are also m rabbits, the rabbit labeled i comes to hole ki in time ti. Now you have p原创 2017-07-25 17:55:37 · 652 阅读 · 0 评论 -
HDU1069-Monkey and Banana
Monkey and BananaTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 16168 Accepted Submission(s): 8597Problem Description A group of researche原创 2017-08-16 21:55:09 · 330 阅读 · 0 评论 -
HDU1024-Max Sum Plus Plus
Max Sum Plus PlusTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 31033 Accepted Submission(s): 10942Problem Description Now I think you hav原创 2017-08-16 09:44:27 · 487 阅读 · 0 评论 -
POJ1463-Strategic game
Strategic gameTime Limit: 2000MS Memory Limit: 10000K Total Submissions: 8433 Accepted: 3945 DescriptionBob enjoys playing computer games, especially strategic games, but sometimes he cannot原创 2017-08-08 10:44:42 · 332 阅读 · 0 评论 -
CF835C-Star sky
C. Star skytime limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output The Cartesian coordinate system is set in the sky. There you can see n stars, th原创 2017-08-01 09:23:09 · 553 阅读 · 0 评论 -
COJ1973-给自己出题的小X
给自己出题的小XSubmit Page Summary Time Limit: 1 Sec Memory Limit: 128 Mb Submitted: 126 Solved: 43 Description 小X学习了dfs,为了练习搜索,开始给自己出题玩。 玩着玩着,一会把自己难住了,一会又被自己难倒了,真是有趣诶! 小X出的题: 现在有N个不同的原创 2017-07-29 19:20:41 · 474 阅读 · 0 评论 -
UVA-10590 正整数拆分
Boxes of Chocolates AgainLittle Pippy has got again a big bunch of boxes of chocolates on her 7-th birthday. Her parents are anxious about the health of her teeth, so they have allowed her to take onl原创 2017-05-21 11:13:28 · 731 阅读 · 0 评论 -
HDU2089-不要62
不要62Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 45207 Accepted Submission(s): 16914Problem Description 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。 杭州交原创 2017-08-20 10:19:18 · 264 阅读 · 0 评论 -
HDU6156-Palindrome Function
Palindrome FunctionTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 256000/256000 K (Java/Others) Total Submission(s): 431 Accepted Submission(s): 230Problem Description As we all know,a pa原创 2017-08-20 11:39:06 · 328 阅读 · 0 评论 -
数位dp-CF55D
#include<bits/stdc++.h>using namespace std;const int MAXN=2520+5;typedef long long LL;int Hash[MAXN],bit[20];LL dp[20][50][MAXN];int gcd(int a,int b) {return b==0?a:gcd(b,a%b);}int lcm(i...原创 2018-08-05 15:02:10 · 229 阅读 · 0 评论 -
Dynamic time warping
import math#the distance between two node in the time seriesdef calcdist(x,y): # if the node is a list if type(x) == 'list': length = len(x) sum = 0 for i in range(l...转载 2018-07-16 17:30:17 · 658 阅读 · 0 评论 -
CF983B
传送门:CF983B/*区间dp,异或的性质*/#include<iostream>#include<cstdio>#include<vector>#include<algorithm>#include<cstring>#include<string>#include<cmath>usin原创 2018-05-16 16:04:50 · 553 阅读 · 0 评论 -
UVALive - 7426 -Debugging
Your fancy debugger will not help you in this matter. There are many ways in which code can produce different behavior between debug and release builds, and when this happens, one may have to resor原创 2017-10-01 19:04:48 · 420 阅读 · 0 评论 -
有关计数问题的dp
1、划分数 有nn个无区别的物品,将它们划分成不超过mm组,求出划分方法数模MM的余数。 dp[i][j]dp[i][j]表示jj的ii划分的总数 考虑nn的mm划分ai(∑i=1mai=n)a_i(\sum\limits_{i=1}^{m}a_i=n),如果对于每个ii都有ai>0a_i>0,那么ai−1{a_i-1}就对应了n−mn-m的mm划分。另外,如果存在ai=0a_i=0,那么这就原创 2017-08-26 15:30:21 · 905 阅读 · 0 评论 -
HDU5532 Almost Sorted Array
Almost Sorted ArrayTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 3138 Accepted Submission(s): 791Problem Description We are all familia原创 2016-09-28 17:21:21 · 492 阅读 · 0 评论 -
HDU4405
Aeroplane chessTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3405 Accepted Submission(s): 2164Problem DescriptionHzz loves ae原创 2016-08-22 17:07:56 · 475 阅读 · 0 评论 -
2017"百度之星"程序设计大赛 - 初赛-Chess
ChessAccepts: 1805 Submissions: 5738 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description車是中国象棋中的一种棋子,它能攻击同一行或同一列中没有其他棋子阻隔的棋子。一天,小度在棋盘上摆起了许多車……他想知道,在原创 2017-08-14 12:50:16 · 374 阅读 · 0 评论 -
CF837D-Round Subset
D. Round Subsettime limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Let’s call the roundness of the number the number of zeros to which it ends.原创 2017-08-06 10:14:08 · 1004 阅读 · 0 评论 -
POJ3356-AGTC(编辑距离)
AGTCTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 13042 Accepted: 4917 DescriptionLet x and y be two strings over some finite alphabet A. We would like to transform x into y原创 2017-05-31 17:03:45 · 603 阅读 · 0 评论 -
HDU2602-Bone Collector(01背包)
Bone CollectorTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 61285 Accepted Submission(s): 25542Problem Description Many years ago , in Te原创 2017-05-29 11:59:39 · 427 阅读 · 0 评论 -
2017湖南多校第二场-20170312
F(1833): Lab Submit Status Time Limit: 1 Sec Memory Limit: 128 Mb Submitted: 35 Solved: 12 Description Susan, your friend, is working in a biology lab. She is working in a very s原创 2017-03-15 13:40:28 · 531 阅读 · 0 评论 -
HDU1466
计算直线的交点数Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9596 Accepted Submission(s): 4377Problem Description平面上有n条直线,且无三线共点,问原创 2016-11-13 11:21:15 · 527 阅读 · 0 评论 -
POJ1837
BalanceTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 13676Accepted: 8590DescriptionGigel has a strange "balance" and he wants to poise it. Actually,原创 2016-09-04 12:44:16 · 331 阅读 · 0 评论 -
UVA12563
题意:n首歌,每首歌有其长度,还剩t秒,不包括678秒的《劲歌金曲》输出唱的总曲目和时间总长度紫书P274页题目传送门:UVA12563听学长讲,可以转化为0-1背包#include#include#include#includeusing namespace std;const int MAX = 10000;int main(){原创 2016-08-22 16:27:45 · 863 阅读 · 0 评论 -
POJ2533
Longest Ordered SubsequenceTime Limit: 2000MSMemory Limit: 65536KTotal Submissions: 47349Accepted: 21056DescriptionA numeric sequence of ai is ordered if a1 a原创 2016-08-22 16:19:57 · 340 阅读 · 0 评论 -
POJ1458
Common SubsequenceTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 48076Accepted: 19816DescriptionA subsequence of a given sequence is the given sequenc原创 2016-08-22 16:14:11 · 460 阅读 · 0 评论 -
SCU1114
D -数字三角Crawling in process...Crawling failedTime Limit:0MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmitStatus Practice SCU 1114 uDebugDescription原创 2016-08-22 16:09:54 · 489 阅读 · 0 评论 -
UVA12034
题意:n匹马比赛的所有可能结果总数题目传送门:UVA12034动态规划,dp[i][j]表示i匹马j个排名递推关系:dp[i][j]=(dp[i-1][j-1]+dp[i-1][j])%Mod*j%Mod;与前面的马同时到达+单独到达~注意取模的运算规则#include #include #include using namespace std;原创 2016-08-22 16:03:36 · 761 阅读 · 0 评论 -
UVA580
题意:一个栈中只能放U和L,3个U会爆炸,给出UL的总数,求会爆炸的个数。题目传送门:UVA580动态规划题,关键是赋予dp[i][j]一个特定的含义~~~dp[i][0]表示第i位由L结尾的安全总数dp[i][1],dp[i][2]分别表示第i位有一个U和两个U结尾的安全总数最后运用补集思想求出危险总数。递推关系:dp[i][0]=dp[i-1][0]+d原创 2016-08-22 15:53:27 · 458 阅读 · 0 评论 -
UVA10917 Walk Through the Forest
Jimmy experiences a lot of stress at work these days, especially since his accident made working difficult. To relax after a hard day, he likes to walk home. To make things even nicer, his office原创 2017-04-10 22:22:38 · 474 阅读 · 0 评论 -
POJ1163-The Triangle(数字三角形)
The TriangleTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 48823 Accepted: 29496 Description7 3 8 8 1 0 2 7 4 4 4 5 2 6 5(Figure 1) Figure 1 shows a n原创 2017-04-29 22:15:27 · 946 阅读 · 0 评论 -
UVA10304-Optimal Binary Search Tree(最优二分检索树)
Optimal Binary Search TreeGiven a set S = (e1, e2, …, en) of n distinct elements such that e1 < e2 < … < en and considering a binary search tree (see the previous problem) of the elements of S, it is原创 2017-05-26 09:19:03 · 1150 阅读 · 0 评论 -
中南大学第十一届大学生程序设计竞赛-COJ1899-Yuelu Scenes
1899: Yuelu ScenesSubmit Page Summary Time Limit: 1 Sec Memory Limit: 256 Mb Submitted: 4 Solved: 3 Description An artist begins with a roll of ribbon, one inch wide. She clips it原创 2017-04-26 10:50:42 · 754 阅读 · 0 评论 -
HDU1003-Max Sum
Max SumTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 244466 Accepted Submission(s): 57714Problem Description Given a sequence a[1],a[2],a原创 2017-05-17 12:16:27 · 386 阅读 · 0 评论 -
最长公共子序列(LCS)
示例题目:HDU1159 参考资料:《挑战程序设计竞赛》Common SubsequenceTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 38171 Accepted Submission(s): 17503Problem De原创 2017-04-27 21:40:16 · 462 阅读 · 0 评论 -
最长上升子序列
示例题目:POJ2533 参考书籍:《挑战程序设计竞赛》第一种方法:O(n^2) dp[i]:以a[i]结尾的最长上升子序列的长度只包含a[i]的序列 由a[j]追加a[i]得到(满足j< i并且a[j]< a[i])状态转移方程: dp[i]=max{dp[i],dp[j]+1}#include<iostream>#include<cstring>#include<cmath>#原创 2017-04-27 18:40:02 · 891 阅读 · 0 评论 -
HDU1423&POJ2127-Greatest Common Increasing Subsequence
Greatest Common Increasing SubsequenceTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7674 Accepted Submission(s): 2484Problem Description原创 2017-05-24 16:38:56 · 462 阅读 · 0 评论