DP
cherish__lin
I want to be better!
展开
-
W - Test for Job (记忆化搜索)
Mr.Dog was fired by his company. In order to support his family, he must find a new job as soon as possible. Nowadays, It's hard to have a job, since there are swelling numbers of the unemployed. S...原创 2019-02-09 22:01:56 · 186 阅读 · 0 评论 -
A - How to Type(dp)
Pirates have finished developing the typing software. He called Cathy to test his typing software. She is good at thinking. After testing for several days, she finds that if she types a string by some...原创 2019-03-09 19:07:21 · 195 阅读 · 0 评论 -
最长公共子序列问题(LCS简单dp)
Problem Description给定两个序列 X={x1,x2,…,xm} 和 Y={y1,y2,…,yn},找出X和Y的最长公共子序列。Input输入数据有多组,每组有两行 ,每行为一个长度不超过500的字符串(输入全是大写英文字母(A,Z)),表示序列X和Y。Output每组输出一行,表示所求得的最长公共子序列的长度,若不存在公共子序列,则输出0。Sample I...原创 2019-03-04 21:24:44 · 458 阅读 · 0 评论 -
F - Divisibility POJ - 1745
Consider an arbitrary sequence of integers. One can place + or - operators between integers in the sequence, thus deriving different arithmetical expressions that evaluate to different values. Let ...原创 2019-03-08 09:36:11 · 178 阅读 · 0 评论 -
L3-020 至多删三个字符 (30 分)(dp)
给定一个全部由小写英文字母组成的字符串,允许你至多删掉其中 3 个字符,结果可能有多少种不同的字符串?输入格式:输入在一行中给出全部由小写英文字母组成的、长度在区间 [4, 106] 内的字符串。输出格式:在一行中输出至多删掉其中 3 个字符后不同字符串的个数。输入样例:ababcc输出样例:25提示:删掉 0 个字符得到 "ababcc"。...原创 2019-03-23 19:47:46 · 1270 阅读 · 0 评论 -
R - Race to 1 (期望)
Dilu have learned a new thing about integers, which is - any positive integer greater than 1 can be divided by at least one prime number less than or equal to that number. So, he is now playing with t...原创 2019-04-20 23:08:33 · 254 阅读 · 0 评论 -
P - A Dangerous Maze (II) (期望)
You are in a maze; seeingndoors in front of you in beginning. You can choose any door you like. The probability for choosing a door is equal for all doors.If you choose theithdoor, it can either...原创 2019-04-20 23:35:47 · 212 阅读 · 0 评论 -
C - 不要62 HDU - 2089
杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。不吉利的数字为所有含有4或62的号码。例如:62315 73418 88914都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之列。你...原创 2019-05-01 20:47:41 · 139 阅读 · 0 评论 -
E - Round Numbers POJ - 3252
The cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, Paper, Stone' (also known as 'Rock, Paper, Scissors', 'Ro, Sham, Bo', and a host of other names) in order to make...原创 2019-05-14 21:35:36 · 167 阅读 · 0 评论 -
A - Beautiful numbers CodeForces - 55D
Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with...原创 2019-05-14 21:54:11 · 148 阅读 · 0 评论 -
C. Painting the Fence(暴力)
You have a long fence which consists of原创 2019-03-06 20:23:36 · 1327 阅读 · 2 评论 -
最长上升子序列(dp经典)
Problem Description一个数的序列bi,当b1 < b2 < ... < bS的时候,我们称这个序列是上升的。对于给定的一个序列(a1, a2, ..., aN),我们可以得到一些上升的子序列(ai1, ai2, ..., aiK),这里1<= i1 < i2 < ... < iK <= N。比如,对于序列(1, 7, 3, 5,...原创 2019-03-08 21:44:48 · 1197 阅读 · 0 评论 -
【算法设计与数据结构】动态规划入门——URAL 1119 Metro
Many of SKB Kontur programmers like to get to work by Metro because the main office is situated quite close the station Uralmash. So, since a sedentary life requires active exercises off-duty, many of...原创 2019-02-27 23:11:21 · 108 阅读 · 0 评论 -
数字矩阵(dp)
Problem DescriptionbLue 站在了一个 n*m 的填有数字的矩阵中,他可以选择从矩阵的四个顶点之一出发,到达斜对面的顶点。每一步必须向靠近目的地的方向移动,且每次移动都可以累加所在位置上的数字。例如,bLue 选择从左上角出发,那么目的地为右下角,则他每次只能向右或向下移动一格。现在他想知道在所有的走法中,能获得的最大累加和是多少。你能帮助他吗?Input输...原创 2019-02-23 21:32:05 · 1072 阅读 · 0 评论 -
C~K的奖券(01背包)
Problem Description超市举行兑奖活动啦!!!C~K 费劲心力,终于搞到了 m 张兑奖券,而奖品区有 n 件奖品,分别标号为 1~n,其中第 i 件奖品需要 need(i) 张奖券进行兑换,同时也只能兑换一次,为了辛苦得到的奖券不能够浪费,C~K 给每件奖品都评了分,其中第i件奖品的评分值为 value(i),表示 C~K 对这件奖品的喜好值,现在他想知道,凭借他手上的这些...原创 2019-02-23 21:49:30 · 126 阅读 · 0 评论 -
D - K-based Numbers. Version 3 (矩阵快速幂+dp)
Let’s consider K-based numbers, containing exactly N digits. We define a number to be valid if its K-based notation doesn’t contain two successive zeros. For example:1010230 is a valid 7-digit numbe...原创 2019-02-24 21:42:14 · 130 阅读 · 0 评论 -
ural 1073. Square Country 动态规划
There live square people in a square country. Everything in this country is square also. Thus, the Square Parliament has passed a law about a land. According to the law each citizen of the country has...原创 2019-03-01 12:50:07 · 120 阅读 · 0 评论 -
1353. Milliard Vasya's Function
Vasya is the beginning mathematician. He decided to make an important contribution to the science and to become famous all over the world. But how can he do that if the most interesting facts such as ...原创 2019-03-02 00:30:57 · 115 阅读 · 0 评论 -
E - Tickets (dp)
Jesus, what a great movie! Thousands of people are rushing to the cinema. However, this is really a tuff time for Joe who sells the film tickets. He is wandering when could he go back home as early as...原创 2019-02-20 22:52:41 · 274 阅读 · 0 评论 -
辉姐姐与复读机(dp)
Problem Description一天,辉姐姐在 SDUT2018ACM 群里发了一句“我好强啊”,然后经过qyn复读之后变成了 “我好菜啊”,调查发现群里的复读机有坏掉的复读机,坏掉的复读机会产生错误。错误可能的形式如下:(1) 将任意一个位置的小写字母替换成另一个小写字母(2)在任意位置添加任意一个字母(3)在任意位置删除任意一个字母辉姐姐发了一句只包含小写字母的话,收到了一...原创 2019-03-06 09:43:02 · 211 阅读 · 0 评论 -
E - Alignment (最长上升子序列)
In the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are aligned in a straight line in front of the captain. The captain is not satisfied with the way his sold...原创 2019-03-08 20:33:30 · 246 阅读 · 0 评论 -
D - Nim POJ - 2068 (记忆化搜索)
Let's play a traditional game Nim. You and I are seated across a table and we have a hundred stones on the table (we know the number of stones exactly). We play in turn and at each turn, you or I can ...原创 2019-05-18 19:54:52 · 136 阅读 · 0 评论