
动态规划
文章平均质量分 77
whai362
这个作者很懒,什么都没留下…
展开
-
codeforces 514E Darth Vader and Tree (dp+快速幂)
codeforces 514E Darth Vader and Tree (dp+快速幂)题意:有一棵树,每个节点有n个儿子,给出父亲到每个儿子的距离di,问离祖先距离不超过x的子孙有多少个(子孙包括祖先)对1e9+7取模。限制:1 思路:因为di 大概过程为:先用dp算出前100的答案,剩下的用快速幂来处理。/*codeforces 514E Darth原创 2015-02-16 12:50:45 · 1199 阅读 · 0 评论 -
codeforces 540 D. Bad Luck Island (概率dp)
D. Bad Luck Islandtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Bad Luck Island is inhabited by thre原创 2015-09-30 11:47:09 · 794 阅读 · 0 评论 -
codeforces 580 D. Kefa and Dishes (状压dp)
D. Kefa and Dishestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhen Kefa came to the restaurant and sat原创 2015-09-30 16:04:07 · 943 阅读 · 0 评论 -
codeforces 587 B. Duff in Beach
B. Duff in Beachtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhile Duff was resting in the beach, she a原创 2015-10-23 14:21:43 · 777 阅读 · 0 评论 -
The 2015 ACM-ICPC Asia Beijing Regional Contest K A Math Problem
思路:经过分析可得:f(2 * k) = 3 * f(k)f(2 * k + 1) = 3 * f(k) + 1然后:f(x) = 把x用二进制表示出来后,用三进制来计算得到的数值如:x = 5时,二进制为101,所以f(5) = 1 * 3^2 + 0 * 3^1 + 1 * 3^0 = 10有了这个之后我们把1~n的数,变成二进制,写成一列,比如n = 5类原创 2015-11-16 18:55:35 · 1165 阅读 · 0 评论 -
hdu 5593 ZYB's Tree
ZYB's Tree Accepts: 77 Submissions: 513 Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)问题描述ZYBZYB有一颗NN个节点的树,现在他希望你对于每一个点,求出离每个点距离不超过KK的点原创 2015-12-09 20:59:04 · 604 阅读 · 0 评论 -
codeforces 602 E. Kleofáš and the n-thlon (概率dp)
E. Kleofáš and the n-thlontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKleofáš is participating in an n-原创 2015-11-27 10:25:14 · 854 阅读 · 0 评论 -
codeforces 488 D. Strip
D. Striptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlexandra has a paper strip with n numbers on it. L原创 2015-12-06 21:35:28 · 601 阅读 · 0 评论 -
codeforces 498 b Name That Tune
codeforces 498 b Name That Tune题目连接点击打开链接题意:猜歌游戏,给出每次每首歌猜中的概率pi,和每首歌最多猜的次数ti(一秒一次,等于ti次一定会成功),给出n首歌的pi和ti,给出游戏进行时间T,问T秒后猜中的歌的数目的期望。限制:1 思路:概率dpdp[i][j] 表示 在第j秒猜中了i首歌的概率dp[i][j] = ( d原创 2014-12-30 11:00:53 · 1079 阅读 · 0 评论 -
bzoj 1030: [JSOI2007]文本生成器 (ac自动机上的dp)
1030: [JSOI2007]文本生成器Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 2635 Solved: 1090[Submit][Status][Discuss]DescriptionJSOI交给队员ZYX一个任务,编制一个称之为“文本生成器”的电脑软件:该软件的使用者是一些低幼人群,他们现在使用的是GW文本生成器原创 2015-08-17 12:12:02 · 780 阅读 · 0 评论 -
codeforces 571 B. Minimization
B. Minimizationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou've got array A, consisting of n integer原创 2015-08-24 22:01:06 · 820 阅读 · 0 评论 -
hdu 5180 状态压缩 dp 打表
hdu 5180 状态压缩 dp 打表题意:在n*n的国际象棋中,放置若干个国王和k个车,使得国王之间不互相攻击,车之间不互相攻击,车不可攻击到国王(这并不代表国王不能攻击到车)。国王能攻击到它上下左右,左上左下右上右下八个位置的棋子,车可以攻击到同一行或同一列中的棋子,求方案总数对1000000007取模后的值。 限制:1 思路:状态压缩,dp,打表套打表原创 2015-03-07 14:35:45 · 1393 阅读 · 0 评论 -
hdu 5168 Legal path
hdu 5168 Legal path题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5168题意:一个有向图,给定起点终点,每条边上有权值。一条合法的路径定义为相邻边的权值之差不小于K的路径,即路径上每条边的权值至少要比上一条边的权值大K,如果上一条边存在。合法路径的长度定义为路径上的边权值总和。求从起点到终点的合法路径的原创 2015-02-02 00:10:06 · 1267 阅读 · 2 评论 -
hdu 5185 dp
hdu 5185 dp 题目: x[1]+x[2]+x[3]+…+x[n]=n, 这里 0 <= x[i] <= n && 1 <= i <= n x[i] <= x[i+1] <= x[i]+1 && 1 <= i <= n-1 对于一个给定的n,Gorwin想要知道有多少xi的组合满足上述等式。由于结果比较大,输出答案对m取余的结果就行。限制: T组数据:1 <= T <=20原创 2015-03-10 12:06:47 · 1035 阅读 · 0 评论 -
poj 3280 dp 记忆化搜索
poj 3280 题意: 给出n,m, 表示长度为m的字符串里只含n种字母, 给出字符串, 再给出每种字母增加和删除的代价c1,c2, 求把这个字符串变成回文串的最小代价。限制: 1 <= n <= 26; 1 <= m <= 2000; 0 <= c1,c2 <= 10000思路: if(str[l]!=str[r]) dp[l][r]=min(dp[l+1][r]+cost[l],dp[原创 2015-03-10 09:41:12 · 741 阅读 · 0 评论 -
poj 1651 dp 记忆化搜索
poj 1651 dp 记忆化搜索 题意: 给出n个整数a1,a2,…,an,要求从中取出中间的n-2个数(两端的数不能取),取出每个数的代价为它两边的数和它的乘积,问取出这n-2个数的最小代价为多少? 限制: 3 <= n <= 100; 1 <= ai <= 100 思路: dp 记忆化搜索 对于每个过程其实就是,枚举最后取的数a[i],然后把区间[l,r]分割成[l,i]和[i,原创 2015-03-13 15:59:59 · 766 阅读 · 0 评论 -
hdu 5234 Happy birthday
hdu 5234 Happy birthday题意:今天是Gorwin的生日。所以她的妈妈要实现她的一个愿望。Gorwin说她想吃很多蛋糕。所以他妈妈带她来到了蛋糕园。这个园子被分成了n*m个方格子。在每一个格子里面,有一个蛋糕。第i行,第j列的格子中有一个重量为w[i][j]千克的蛋糕,Gorwin从左上角(1,1)的格子开始走,走到右下角(n,m)的格子。在每一步中,Gorwi原创 2015-05-25 11:59:08 · 794 阅读 · 0 评论 -
hdu 4804 Campus Design 轮廓线dp
hdu 4804 Campus Design 轮廓线dp题意:给出一个n*m的01矩阵,其中要求把矩阵里面的1用1*1或1*2的砖块铺满,矩阵里面的0为障碍物,问使用1*1的砖块数>=c && 限制:1 思路:因为 1 具体状态解释在代码中说明。/*hdu 4804 Campus Design 轮廓线dp 题意: 给出一个n*m的01矩阵,其原创 2015-07-09 15:53:23 · 930 阅读 · 0 评论 -
zoj 3822 Domination
zoj 3822 Domination题意:给定一个N*M的棋盘,每次任选一个位置放置一枚棋子,直到每行每列上都至少有一枚棋子,问放置棋子个数的期望。限制:1 思路:概率dpdp[i][j][k]表示用了k个棋子,占了i行j列。/*zoj 3822 Domination 题意: 给定一个N*M的棋盘,每次任选一个位置放置一枚棋子,直到每行每列原创 2015-07-15 20:05:51 · 806 阅读 · 0 评论 -
codeforces 498 e Stairs and Lines
codeforces 498 e Stairs and Lines题目链接点击打开链接题意:给出7个阶梯的宽度wi,阶梯的高度是一定的,阶梯排在一起形成一个图案,现在问在图案内部加入一些横线或竖线使得每个方格都不被线包围。限制:0 思路:dp,快速幂文字好难表述。。。原创 2014-12-30 13:53:30 · 1710 阅读 · 0 评论