随笔分类 - 动态规划
摘要:今天练了一波DP。时间紧迫我就只贴代码了。20141120fzu2129http://acm.fzu.edu.cn/problem.php?pid=2129不同的子序列个数 1 //#pragma comment(linker, "/STACK:102400000,102400000") 2 #...
阅读全文
摘要:http://codeforces.com/gym/100405D题题在pdf里codeforces.com/gym/100405/attachments/download/2331/20132014-acmicpc-northwestern-european-regional-contest-nw...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=50092014网络赛 西安 比较难的题Paint PearlsTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Othe...
阅读全文
摘要:Codeforces Round #267 (Div. 2)C. George and Jobtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTh...
阅读全文
摘要:CF462DCodeforces Round #263 (Div. 2) DCodeforces Round #263 (Div. 1) BB. Appleman and Treetime limit per test2 secondsmemory limit per test256 megabyt...
阅读全文
摘要:ZOJ Monthly, August 2014 E题ZOJ月赛 2014年8月 E题http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5334Easy 2048 AgainTime Limit: 2 Seconds Memory ...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=49762014 Multi-University Training Contest 10 1006A simple greedy problem.Time Limit: 2000/1000 MS (Java/Oth...
阅读全文
摘要:CF453B CF454DCodeforces Round #259 (Div. 2) DCodeforces Round #259 (Div. 1) BD. Little Pony and Harmony Chesttime limit per test4 secondsmemory limit ...
阅读全文
摘要:Codeforces Round #261 (Div. 2)E - Pashmak and Graph E. Pashmak and Graphtime limit per test1 secondmemory limit per test256 megabytesinputstandard inp...
阅读全文
摘要:http://poj.org/problem?id=3254Corn FieldsTime Limit: 2000MSMemory Limit: 65536KTotal Submissions: 7588Accepted: 4050DescriptionFarmer John has purchas...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3555BombTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Submission(s...
阅读全文
摘要:2014多校7 第二水的题4939Stupid Tower DefenseTime Limit: 12000/6000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 366Accept...
阅读全文
摘要:Codeforces Round #258 (Div. 2)Count Good SubstringsD. Count Good Substringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard...
阅读全文
摘要:D - A Lot of Games CF#260 Div2 D题CF#260 Div1 B题Codeforces Round #260CF455BD. A Lot of Gamestime limit per test1 secondmemory limit per test256 megabyt...
阅读全文
摘要:UvaLive6661PDF题目题意:让你用1~n中k个不同的数组成s,求有多少种组法。题解:DFS或者DP或打表。1.DFS 由于数据范围很小,直接dfs每种组法统计个数即可。 1 //#pragma comment(linker, "/STACK:102400000,102400000") 2 ...
阅读全文
摘要:链接:CF360B题目:B. Levko and Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLevko has an array...
阅读全文
摘要:最长上升子序列、最长不下降子序列,解法差不多,就一点等于不等于的差别,我这里说最长不下降子序列的。有两种解法。一种是DP,很容易想到,就这样:1 REP(i,n)2 {3 f[i]=1;4 FOR(j,0,i-1)5 ...
阅读全文
摘要:简单的DP。f[i][j]表示序列a中前i个中,序列b中前b个中,组成的最长公共子序列的长度。DP方程:if(a[i-1]==b[j-1]) f[i][j]=f[i-1][j-1]+1; else f[i][j]=max(f[i-1][j],f[i][j-1]);(我这个a下标是从0开始,f是从1开...
阅读全文
摘要:链接:Piggy-Bank大意:已知一只猪存钱罐空的时候的重量、现在的重量,已知若干种钱的重量和价值,猪里面装着若干钱若干份,求猪中的钱的价值最小值。题解:DP,完全背包。g[j]表示组成重量j的最小花费g[j]=min(g[j],g[j-w[i]]+v[i])完全背包物品可以多次使用,所以j的循环...
阅读全文
摘要:比基础的多一点东西的背包问题。链接:POJ2642大意:有N种砖,每种花费p[i],含铜量c[i],现需要用M种不同的砖融成含铜量在Cmin到Cmax之间(可等于)的砖,即这M种砖的含铜量平均值在这个范围内,求最小花费。(M、Cmin、Cmax有多种需求,分别输出花费)题解:DP,f[i][j]表示...
阅读全文