随笔分类 -  动态规划

摘要:不要62 HDU - 2089 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。 不吉利的数字为所有含有4或62的号码。例如:  阅读全文
posted @ 2019-01-25 21:44 *starry* 阅读(207) 评论(0) 推荐(0)
摘要:Ilya Muromets Gym - 100513F Силачом слыву недаром — семерых одним ударом! From the Russian cartoon on the German fairy tale. Силачом слыву недаром — с 阅读全文
posted @ 2018-12-05 11:52 *starry* 阅读(478) 评论(0) 推荐(0)
摘要:Brackets POJ - 2955 We give the following inductive definition of a “regular brackets” sequence: the empty sequence is a regular brackets sequence, if 阅读全文
posted @ 2018-12-04 16:56 *starry* 阅读(330) 评论(0) 推荐(0)
摘要:Easy Game LightOJ - 1031 You are playing a two player game. Initially there are n integer numbers in an array and player A and B get chance to take th 阅读全文
posted @ 2018-12-04 15:40 *starry* 阅读(198) 评论(0) 推荐(0)
摘要:Beauty of Array ZOJ - 3872 Edward has an array A with N integers. He defines the beauty of an array as the summation of all distinct integers in the a 阅读全文
posted @ 2018-12-03 20:03 *starry* 阅读(298) 评论(0) 推荐(0)
摘要:小乐乐下象棋 链接:https://ac.nowcoder.com/acm/contest/301/F来源:牛客网 题目描述 小乐乐一天天就知道玩,这一天又想玩象棋。 我们都知道马走日。 现在给定一个棋盘,大小是n*m,把棋盘放在第一象限,棋盘的左下角是(0,0),右上角是(n - 1, m - 1 阅读全文
posted @ 2018-12-02 21:38 *starry* 阅读(176) 评论(0) 推荐(0)
摘要:Strategic game POJ - 1463 Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and the 阅读全文
posted @ 2018-11-19 21:22 *starry* 阅读(348) 评论(0) 推荐(0)
摘要:Y HDU - 4705 题意:给你一棵树,n个节点n-1条边(双向),树上任意三个点不在一条路径上,统计这样的三点集合有多少种。 思路: n个节点中任选3个点的方案数为n*(n-1)*(n-2)/6,从中减去三个点在同一条路径上的种类数即为答案。如何找在同一条路径上的方案数呢,就是以固定某一个点, 阅读全文
posted @ 2018-11-14 20:01 *starry* 阅读(221) 评论(0) 推荐(1)
摘要:Average distance HDU - 2376 Given a tree, calculate the average distance between two vertices in the tree. For example, the average distance between t 阅读全文
posted @ 2018-11-14 19:30 *starry* 阅读(309) 评论(0) 推荐(0)
摘要:Party at Hali-Bula UVA - 1220 题意: 公司里有n(n<=200)个人形成一个树状结构, 要求尽量选多的人,但不能同时选择一个人和他的直属上司,文最多能选多少人,以及是否方案唯一。 阅读全文
posted @ 2018-11-11 16:13 *starry* 阅读(182) 评论(0) 推荐(0)
摘要:Almost Arithmetical Progression CodeForces - 255C Gena loves sequences of numbers. Recently, he has discovered a new type of sequences which he called 阅读全文
posted @ 2018-11-11 14:46 *starry* 阅读(260) 评论(0) 推荐(0)
摘要:Anniversary party HDU - 1520 There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierar 阅读全文
posted @ 2018-11-11 10:56 *starry* 阅读(581) 评论(0) 推荐(0)
摘要:Cards and Joy CodeForces - 999F There are nn players sitting at the card table. Each player has a favorite number. The favorite number of the j-th pla 阅读全文
posted @ 2018-11-08 19:35 *starry* 阅读(262) 评论(0) 推荐(0)
摘要:石子归并 51Nod - 1021 N堆石子摆成一条线。现要将石子有次序地合并成一堆。规定每次只能选相邻的2堆石子合并成新的一堆,并将新的一堆石子数记为该次合并的代价。计算将N堆石子合并成一堆的最小代价。 例如: 1 2 3 4,有不少合并方法 1 2 3 4 => 3 3 4(3) => 6 4( 阅读全文
posted @ 2018-10-08 17:45 *starry* 阅读(135) 评论(0) 推荐(0)
摘要:Hometask codeforces 155C Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sen 阅读全文
posted @ 2018-10-05 11:31 *starry* 阅读(250) 评论(0) 推荐(0)
摘要:放苹果 POJ - 1664 把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法。 Input 第一行是测试数据的数目t(0 <= t <= 20)。以下每行均包含二个整数M和N,以空格分开。1<=M,N<=10。 O 阅读全文
posted @ 2018-09-26 21:17 *starry* 阅读(252) 评论(0) 推荐(0)
摘要:Bear and Blocks CodeForces - 574D Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row 阅读全文
posted @ 2018-09-25 17:02 *starry* 阅读(219) 评论(0) 推荐(0)
摘要:Bone Collector II HDU - 2639 The title of this problem is familiar,isn't it?yeah,if you had took part in the "Rookie Cup" competition,you must have se 阅读全文
posted @ 2018-09-08 17:16 *starry* 阅读(153) 评论(0) 推荐(0)
摘要:HDU-3664 Permutation Counting Given a permutation a1, a2, … aN of {1, 2, …, N}, we define its E-value as the amount of elements where ai > i. For exam 阅读全文
posted @ 2018-08-28 17:00 *starry* 阅读(137) 评论(0) 推荐(0)
摘要:HDU 3535 AreYouBusy 题解:dp[i][j]表示的是在第i组剩余时间为j时的快乐值,我们需要对每一组工作进行一次DP。 第一类:即s==0时,表示该组中工作必须要选且至少选一项。为了保证不出现不选的现象,我们应该把DP数组初始化为负无穷。状态转移方程为: dp[i][k]=max( 阅读全文
posted @ 2018-08-16 19:21 *starry* 阅读(145) 评论(0) 推荐(0)