
动态规划
LucienShui
因为孤独是人之常态,所以陪伴才显得格外可贵。
展开
-
销售 - 动态规划
销售 - 动态规划原文链接https://blog.lucien.ink/archives/456/题目地址http://icpc.upc.edu.cn/problem.php?id=12765题目农夫 John 正在筹划从他的谷仓中售出 N 头奶牛,与此同时也有 N 个农夫想要购买奶牛。每个农夫都有刚好足够购买一头奶牛的钱并且将会把买来的这头奶牛用来挤奶。为了减少买来的牛挤不出奶的风...原创 2019-07-13 11:11:27 · 360 阅读 · 0 评论 -
洛谷P1736 - 创意吃鱼法 - 动态规划
题解链接https://lucien.ink/archives/220/题目链接https://www.luogu.org/problemnew/show/P1736题目题目描述回到家中的猫猫把三桶鱼全部转移到了她那长方形大池子中,然后开始思考:到底要以何种方法吃鱼呢(猫猫就是这么可爱,吃鱼也要想好吃法 ^_*)。她发现,把大池子视为01矩阵(0表示对应位置无鱼...原创 2018-05-16 16:22:47 · 465 阅读 · 0 评论 -
洛谷P1855 - 榨取kkksc03 - 动态规划
题解链接https://lucien.ink/archives/219/题目链接https://www.luogu.org/problemnew/show/P1855题目洛谷的运营组决定,如果一名oier向他的教练推荐洛谷,并能够成功的使用(成功使用的定义是:该团队有20个或以上的成员,上传10道以上的私有题目,布置过一次作业并成功举办过一次公开比赛),那么他可以浪费掉...原创 2018-05-16 15:55:00 · 231 阅读 · 0 评论 -
洛谷P1417 - 烹调方案 - 动态规划
题解链接https://lucien.ink/archives/218/题目链接https://www.luogu.org/problemnew/show/P1417题目题目背景由于你的帮助,火星只遭受了最小的损失。但gw懒得重建家园了,就造了一艘飞船飞向遥远的earth星。不过飞船飞到一半,gw发现了一个很严重的问题:肚子饿了~gw还是会做饭的,于是拿出了储藏...原创 2018-05-16 15:48:48 · 258 阅读 · 0 评论 -
洛谷P1387 - 最大正方形 - 动态规划
题解链接:https://lucien.ink/archives/217/题目链接:https://www.luogu.org/problemnew/show/P1387题目:题目描述在一个n*m的只包含0和1的矩阵里找出一个不包含0的最大正方形,输出边长。输入格式:输入文件第一行为两个整数n,m(1<=n,m<=100),接下来n行,每...原创 2018-05-16 15:32:34 · 450 阅读 · 0 评论 -
洛谷P1006 - 传纸条 - 动态规划
题解链接:https://lucien.ink/archives/216/题目链接:https://www.luogu.org/problemnew/show/P1006题目:题目描述小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题。一次素质拓展活动中,班上同学安排做成一个m行n列的矩阵,而小渊和小轩被安排在矩阵对角线的两端,因此,他们就无法直接交谈了...原创 2018-05-16 15:22:57 · 545 阅读 · 0 评论 -
ARC-060C - Tak and Cards - 动态规划
题解链接https://lucien.ink/archives/228/题目链接https://arc060.contest.atcoder.jp/tasks/arc060_a题目Problem StatementTak has NNN cards. On the iii-th (1≤i≤N)(1≤i≤N)(1≤i≤N) card is written an i...原创 2018-05-20 20:36:19 · 400 阅读 · 0 评论 -
ARC-059F - Unhappy Hacking - 动态规划
题解链接https://lucien.ink/archives/225/题目链接https://arc059.contest.atcoder.jp/tasks/arc059_d题目Problem StatementSig has built his own keyboard. Designed for ultimate simplicity, this keyb...原创 2018-05-18 00:13:18 · 711 阅读 · 0 评论 -
洛谷P1541 - 乌龟棋 - 动态规划
题解链接https://lucien.ink/archives/223/题目链接https://www.luogu.org/problemnew/show/P1541题目题目背景小明过生日的时候,爸爸送给他一副乌龟棋当作礼物。题目描述乌龟棋的棋盘是一行N个格子,每个格子上一个分数(非负整数)。棋盘第1格是唯一的起点,第N格是终点,游戏要求玩家...原创 2018-05-17 22:54:03 · 360 阅读 · 0 评论 -
P1417 - 烹调方案 - 动态规划
题解链接:https://lucien.ink/archives/175/题目链接:https://www.luogu.org/problemnew/show/P1417题目:题目背景由于你的帮助,火星只遭受了最小的损失。但gw懒得重建家园了,就造了一艘飞船飞向遥远的earth星。不过飞船飞到一半,gw发现了一个很严重的问题:肚子饿了~gw还是会做饭的,于是拿出...原创 2018-04-23 23:24:06 · 358 阅读 · 0 评论 -
UPC-5169 - Ingredients - 拓扑排序 & 动态规划
题解链接:https://lucien.ink/archives/185/题目链接:http://codeforces.com/gym/101635/attachments题目:题目描述The chef of a restaurant aspiring for a Michelin star wants to display a selection of her...原创 2018-04-30 20:48:05 · 488 阅读 · 0 评论 -
洛谷P1064 - 金明的预算方案 - 动态规划
题解链接https://lucien.ink/archives/222/题目链接https://www.luogu.org/problemnew/show/P1064题目题目描述金明今天很开心,家里购置的新房就要领钥匙了,新房里有一间金明自己专用的很宽敞的房间。更让他高兴的是,妈妈昨天对他说:“你的房间需要购买哪些物品,怎么布置,你说了算,只要不超过N元钱就行”...原创 2018-05-16 16:30:21 · 420 阅读 · 0 评论 -
Codeforces-987C - Three displays - 动态规划
题解链接http://www.lucien.ink/archives/244/题目链接http://codeforces.com/contest/987/problem/C题目It is the middle of 2018 and Maria Stepanovna, who lives outside Krasnokamensk (a town in Zabaikal...原创 2018-05-30 02:43:58 · 1102 阅读 · 0 评论 -
HD玩具 - 背包
HD玩具原文链接https://blog.lucien.ink/archives/455/题目地址http://icpc.upc.edu.cn/problem.php?id=12163题目商店正在出售小C最喜欢的系列玩具,在接下来的n周中,每周会出售其中的一款,同一款玩具不会重复出现。由于是小C最喜欢的系列,他希望尽可能多地购买这些玩具,但是同一款玩具小C只会购买一个。同时,小C的预...原创 2019-07-08 17:58:07 · 464 阅读 · 0 评论 -
Codeforces - 1155D - Beautiful Array
地址https://codeforces.com/contest/1155/problem/D原文地址https://www.lucien.ink/archives/420/题意你有一个长为 nnn 的序列,你可以选择一个子区间(可以为空),将这个子区间所有的元素乘以 xxx ,问做完上述操作之后这个序列的最大连续区间和可以是多少。题解记状态为 f[i][status] ,其中 st...原创 2019-04-23 15:54:06 · 351 阅读 · 0 评论 -
Codeforces - 1153D - Serval and Rooted Tree
地址https://codeforces.com/contest/1153/problem/D原文地址https://www.lucien.ink/archives/416代码https://pasteme.cn/6251#include <bits/stdc++.h>const int maxn = int(3e5) + 7;std::vector<int>...原创 2019-04-15 00:09:48 · 438 阅读 · 0 评论 -
Codeforces - 1139D - Steps to One
地址https://codeforces.com/contest/1139/problem/D原文地址https://www.lucien.ink/archives/409题意模拟一个循环,一开始有一个空序列,之后每次循环:从 [1,m][1, m][1,m] 中等概率选出一个数字添加到序列里去。检查这个序列所有元素的 gcdgcdgcd 是否为 111,如果为 111 则停...原创 2019-03-25 01:31:05 · 725 阅读 · 0 评论 -
Codeforces 1084D - The Fair Nut and the Best Path - 树形DP
Codeforces 1084A - The Fair Nut and the Best Path - 树形DP题解链接https://lucien.ink题目链接https://codeforces.com/contest/1084/problem/D题意 给你一棵树,数上的每个点都有一个正权值,每条边都有一个负权值,让你在树中找一条简单路径,使得权值和最大。思路 我们...原创 2018-12-11 04:57:36 · 651 阅读 · 0 评论 -
ECNU 3653 - 她的名字 - 动态规划
ECNU 3653 - 她的名字 - 动态规划题解链接https://lucien.ink题目链接https://acm.ecnu.edu.cn/problem/3653/题目“他走过一个又一个星球,却始终放不下对她的思念。“”深情终究是一趟孤独的旅程,她是他永远的牵绊。”我们每个人心中都有一只小狐狸。我们渴望被自己喜欢的人驯服。爱情是彼此之间至为甜蜜的臣服。我们都是傻...原创 2018-12-07 23:19:25 · 539 阅读 · 0 评论 -
BZOJ 4832 - 抵制克苏恩 - 动态规划
BZOJ 4832 - 抵制克苏恩 - 动态规划题解链接https://lucien.ink题目链接https://www.lydsy.com/JudgeOnline/problem.php?id=4832题目小Q同学现在沉迷炉石传说不能自拔。他发现一张名为克苏恩的牌很不公平。如果你不玩炉石传说,不必担心,小Q同学会告诉你所有相关的细节。炉石传说是这样的一个游戏,每个玩家拥有一个 ...原创 2018-12-01 23:49:41 · 243 阅读 · 0 评论 -
Codeforces 1082F - Speed Dial - 动态规划
Codeforces 1082F - Speed Dial - 动态规划题解链接https://lucien.ink题目链接https://codeforces.com/contest/1082/problem/F题目Polycarp’s phone book contains nnn phone numbers, each of them is described by sis_...原创 2018-12-01 01:41:08 · 507 阅读 · 0 评论 -
Codeforces 1082E - Increasing Frequency - 动态规划
Codeforces 1082E - Increasing Frequency - 动态规划题解链接https://lucien.ink题目链接https://codeforces.com/contest/1082/problem/E题目You are given array aaa of length nnn. You can choose one segment [l,r][l...原创 2018-12-01 01:32:37 · 710 阅读 · 0 评论 -
2018徐州邀请赛B - Array - 动态规划
题解链接http://www.lucien.ink/archives/251/题目题目描述JSZKC is the captain of the lala team. There are N girls in the lala team. And their height is [1,N] and distinct. So it means there are no tw...原创 2018-06-06 17:12:46 · 947 阅读 · 0 评论 -
UPC-5434 - Column Addition - 动态规划
题解链接:https://lucien.ink/archives/169/题目链接:http://exam.upc.edu.cn/problem.php?id=5434题目:题目描述A multi-digit column addition is a formula on adding two integers written like this:A m...原创 2018-04-22 15:33:30 · 257 阅读 · 0 评论 -
洛谷P1508 - Likecloud-吃、吃、吃 - 动态规划
题解链接:https://lucien.ink/archives/168/题目链接:https://www.luogu.org/problemnew/show/P1508题目:题目背景问世间,青春期为何物?答曰:“甲亢,甲亢,再甲亢;挨饿,挨饿,再挨饿!”题目描述正处在某一特定时期之中的李大水牛由于消化系统比较发达,最近一直处在饥饿的状态中。某日...原创 2018-04-22 00:49:20 · 255 阅读 · 0 评论 -
UPCOJ-5343 - 兔子 - DP
题目:题目描述做一只明媚的兔子… 兔子都比较喜欢蹦蹦跳跳.但是蹦蹦跳跳的时候如果一直往高处跳的话就太累了,如果一直往低处跳的话就太无聊了.所以兔子希望跳的时候能够往上跳一步,往下跳一步,往上跳一步,往下跳一步….一共经过n个高度互不相同的位置(只要向上跳和向下跳相间分布就可以了,第一步可以往上跳也可以往下跳).如果下一个位置的高度比前一个位置高,就是往上跳,比前一个位置低,就是往下跳原创 2018-01-23 15:31:09 · 347 阅读 · 0 评论 -
Codeforces-55D - Beautiful numbers - 数位DP
题目: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原创 2018-01-13 14:41:06 · 333 阅读 · 0 评论 -
HDU-2084 - 数塔 - 动态规划
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2084题目:Problem Description在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?已经告诉你了,这是个DP的题目,你能AC吗?Input输入数据首先包括一个整数C,表示测试原创 2017-09-07 01:50:41 · 453 阅读 · 0 评论 -
HDU-2044 - 一只小蜜蜂... - 斐波那契
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2044题目:Problem Description有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行。请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数。 其中,蜂房的结构如下所示。Input输入数据的第一行是一个整数N,表示测试实例的个数,然后是N 行数据,每行包含两个整数a和b(0Output对于每原创 2017-09-07 01:46:51 · 417 阅读 · 0 评论 -
HDU-2041 - 超级楼梯 - 斐波那契数列
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2041题目:Problem Description有一楼梯共M级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第M级,共有多少种走法?Input输入数据首先包含一个整数N,表示测试实例的个数,然后是N行数据,每行包含一个整数M(1<=M<=40),表示楼梯的级数。Output对于每个测试实例,请输原创 2017-09-07 01:43:23 · 450 阅读 · 0 评论 -
HDU-2018 - 母牛的故事 - 思维
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2018题目:Problem Description有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?Input输入数据由多个测试实例组成,每个测试实例占一行,包括一个整数n(0Output对于每个测试实例,输出在第n年的时候母原创 2017-09-07 01:41:24 · 383 阅读 · 0 评论 -
Why Did the Cow Cross the Road II - UPCOJ 3438 - 动态规划DP
题目:题目描述 Farmer John raises N breeds of cows (1≤N≤1000), conveniently numbered 1…N. Some pairs of breeds are friendlier than others, a property that turns out to be easily characterized in terms of bre原创 2017-07-28 17:58:23 · 960 阅读 · 0 评论 -
Why Did the Cow Cross the Road - UPCOJ 3437 - BFS + DP
题目:题目描述 Why did the cow cross the road? Well, one reason is that Farmer John’s farm simply has a lot of roads, making it impossible for his cows to travel around without crossing many of them. FJ’s原创 2017-07-28 17:49:36 · 666 阅读 · 0 评论 -
wtaxi - UPCOJ 3641 - 贪心DP 背包
链接: http://exam.upc.edu.cn/problem.php?id=3641题目:题目描述话说小 x 有一次去参加比赛,虽然学校离比赛地点不太远,但小 x 还是想坐出租车去。大学城的出租车总是比较另类,有“拼车”一说,也就是说,你一个人坐车去,还是一堆人一起,总共需要支付的钱是一样的(每辆出租上除司机外最多坐下 4 个人)。刚好那天同校的一群 Oier 在校门口扎堆了,大家果断决定原创 2017-08-01 17:00:06 · 294 阅读 · 0 评论 -
CodeForces-55D - Beautiful numbers - 数位DP
题目: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原创 2018-01-23 16:22:41 · 261 阅读 · 0 评论 -
Codeforces-855B - Marvolo Gaunt's Ring - DP
题目:Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt’s Ring and identified it as a Horcrux. Alth原创 2018-01-23 17:25:04 · 301 阅读 · 0 评论 -
UPC-5243 - 数字删除 - 动态规划
链接:http://exam.upc.edu.cn/problem.php?id=5243题目:题目描述小明最近在研究一个数字删除游戏,正要考考佳佳。游戏规则如下 给定一个正整数,去掉其中若干个数字后剩下的数字按原左右次序将组成一个新的正整数。请问最少删去几个数字,能够使得这个新的正整数合法(不含前导0)且是3的倍数。 小明写下的数字太大,佳佳一时处理不了。请你帮他写一原创 2018-02-01 20:13:04 · 1885 阅读 · 0 评论 -
洛谷P1282 - 多米诺骨牌 - 动态规划
题解链接:https://lucien.ink/archives/167/题目链接:https://www.luogu.org/problemnew/show/P1282题目:题目描述多米诺骨牌有上下2个方块组成,每个方块中有1~6个点。现有排成行的上方块中点数之和记为S1,下方块中点数之和记为S2,它们的差为|S1-S2|。例如在图8-1中,S1=6+1+...原创 2018-04-22 00:43:46 · 562 阅读 · 0 评论 -
UPC-5561 - Optimal Coin Change - 完全背包 & 输出背包路径
题解链接:https://lucien.ink/archives/138/题目链接:http://exam.upc.edu.cn/problem.php?id=5561题目:题目描述In a 10-dollar shop, everything is worthy 10 dollars or less. In order to serve customers m...原创 2018-04-05 19:48:28 · 387 阅读 · 0 评论 -
UPC-5579 - BBQ Hard - 思维 & 组合数学 & 动态规划
题解链接:https://lucien.ink/archives/132/题目链接:http://exam.upc.edu.cn/problem.php?id=5579题目:题目描述Snuke is having another barbeque party.This time, he will make one serving of Skewer Meal...原创 2018-04-04 16:09:31 · 378 阅读 · 0 评论