![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
动态规划
JOY酷酷
这个作者很懒,什么都没留下…
展开
-
LeetCode 877. Stone Game(数学 / dp)
题目链接https://leetcode.com/problems/stone-game/题意一共有 n 堆石子排成一排(n 为偶数),每堆石子个数为 a[i] 个(保证石子总数为基数)。甲乙依次拿取石子,每次只能拿最左或最右的一堆,且两人都采取最优策略,最后获得石子数多的赢。甲为先手,若甲赢则输出 true,否则输出 false。思路1动态规划。设 dp[i][j] 为石子为第 i 堆...原创 2020-01-29 21:45:22 · 185 阅读 · 0 评论 -
HDU 1011 Starship Troopers(树形DP+01背包)
DescriptionYou, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a huge cavern, which consists of many rooms connected with tunn原创 2016-08-08 20:36:13 · 312 阅读 · 0 评论 -
HDU 1024 Max Sum Plus Plus(DP+预处理优化)
Problem DescriptionNow I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you are faced with a more diff原创 2016-08-09 10:57:09 · 192 阅读 · 0 评论 -
HDU 5816 Hearthstone(概率DP+状压)
Problem DescriptionHearthstone is an online collectible card game from Blizzard Entertainment. Strategies and luck are the most important factors in this game. When you suffer a desperate situation原创 2016-08-10 11:24:19 · 505 阅读 · 0 评论 -
HDU 5823 color II(状压DP)
Problem DescriptionYou are given an undirected graph with n vertices numbered 0 through n-1.Obviously, the vertices have 2^n - 1 non-empty subsets. For a non-empty subset S, we define a proper c原创 2016-08-12 16:18:52 · 352 阅读 · 0 评论 -
HDU 1400 Mondriaan's Dream(状压DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1400题意:问1*2的砖块拼成h*w的矩形有多少种拼法。思路:dp[i][j]表示第i行的状态为j时的方法数。如果这个点有砖则为1,没有则为0。注意:时限为10s。因此我们可以枚举行数,枚举i行状态以及i-1行状态,复杂度O(h * 2^w * 2^w)。#include原创 2016-08-13 12:36:06 · 318 阅读 · 0 评论 -
HDU 1423 Greatest Common Increasing Subsequence(DP)
题意:求最长公共上升子序列的长度注意:题目中没有提及,每组输出之间要空一行,最后一次输出不需要空行。思路:dp[i][j]表示A序列的前i个数和B序列的前j个数的最长公共上升子序列的长度。temp[i][j]表示A序列的前i个数和B序列的前j个数的最长公共上升子序列的最后一个数字(如果长度相同的,取最后一个数字最小的)#include #include #inclu原创 2016-08-13 15:15:47 · 217 阅读 · 0 评论 -
HDU 5898 odd-even number(数位DP)
Problem DescriptionFor a number,if the length of continuous odd digits is even and the length of continuous even digits is odd,we call it odd-even number.Now we want to know the amount of odd-even n原创 2016-09-22 17:28:40 · 634 阅读 · 0 评论 -
HDU 5900 QSC and Master(区间DP)
Problem DescriptionEvery school has some legends, Northeastern University is the same.Enter from the north gate of Northeastern University,You are facing the main building of Northeastern Univer原创 2016-09-25 14:02:57 · 231 阅读 · 0 评论 -
HDU 4336 Card Collector(概率DP+状压)
DescriptionIn your childhood, do you crazy for collecting the beautiful cards in the snacks? They said that, for example, if you collect all the 108 people in the famous novel Water Margin, you will原创 2016-09-27 23:03:24 · 296 阅读 · 0 评论 -
HDU 4035 Maze(树上概率DP)
Problem DescriptionWhen wake up, lxhgww find himself in a huge maze.The maze consisted by N rooms and tunnels connecting these rooms. Each pair of rooms is connected by one and only one path. In原创 2016-09-28 17:25:26 · 398 阅读 · 0 评论 -
2015ICPC北京区域赛K. A Math Problem(数位DP)
题意:f[1]=1,3∗f[n]∗(f[2∗n]+1)=f[2∗n]∗(1+3∗f[n]),f[2∗n]定义g[t]为f[i]%k==t的i的个数,求g[0]∧g[1]∧g[2]∧...∧g[k−1]思路:f[1]=1,f[2]=3,f[3]=4,f[4]=9,f[5]=10;可以发现f[i]的三进制表示正好是i的二进制表示比如f[4]=9,9的三进制是10原创 2016-10-29 21:26:37 · 877 阅读 · 0 评论 -
奇虎360 2017春招真题
A、B两伙马贼意外地在一片沙漠中发现了一处金矿,双方都想独占金矿,但各自的实力都不足以吞下对方,经过谈判后,双方同意用一个公平的方式来处理这片金矿。处理的规则如下:他们把整个金矿分成n段,由A、B开始轮流从最左端或最右端占据一段,直到分完为止。马贼A想提前知道他们能分到多少金子,因此请你帮忙计算他们最后各自拥有多少金子?(两伙马贼均会采取对己方有利的策略)#include原创 2017-03-24 21:42:49 · 913 阅读 · 0 评论 -
HDU 5791 Two(DP)
TwoTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 932 Accepted Submission(s): 426Problem DescriptionAlice gets two sequences A and B原创 2016-08-03 13:44:17 · 205 阅读 · 0 评论 -
HDU 1561 The more, The Better(多重背包+树形DP)
Problem DescriptionACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡。你能帮ACboy算出要获得尽量多的宝物应该攻克哪M个城堡吗?Input每个测试实例首先包括2个整数,N,M.(1 =原创 2016-08-17 15:26:00 · 267 阅读 · 0 评论 -
HDU 1513 Palindrome(LCS+滚动数组)
DescriptionA palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are to write a program which, given a string, determines the原创 2016-07-21 19:30:27 · 238 阅读 · 0 评论 -
HDU 1500 Chopsticks(DP)
ChopsticksTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2002 Accepted Submission(s): 944Problem DescriptionIn China, people use a p原创 2016-07-26 11:29:46 · 257 阅读 · 0 评论 -
HDU1227 Fast Food(DP)
DescriptionThe fastfood chain McBurger owns several restaurants along a highway. Recently, they have decided to build several depots along the highway, each one located at a restaurant and supplying原创 2016-07-15 12:02:49 · 248 阅读 · 0 评论 -
HDU1502 Regular Words(DP+大数模拟)
Problem DescriptionConsider words of length 3n over alphabet {A, B, C} . Denote the number of occurences of A in a word a as A(a) , analogously let the number of occurences of B be denoted as B(a),原创 2016-07-26 21:07:59 · 229 阅读 · 0 评论 -
HDU1520 Anniversary party(树形DP)
Anniversary partyTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8869 Accepted Submission(s): 3824Problem DescriptionThere is going t原创 2016-07-27 10:12:14 · 235 阅读 · 0 评论 -
UVA 12105 Bigger is Better(数位DP)
Bob has n matches. He wants to compose numbers using the following scheme (that is, digit 0, 1, 2, 3,4, 5, 6, 7, 8, 9 needs 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 matches):Write a program to make a non-原创 2016-07-27 16:36:02 · 435 阅读 · 0 评论 -
HDU 1466 计算直线的交点数(DP)
Problem Description平面上有n条直线,且无三线共点,问这些直线能有多少种不同交点数。比如,如果n=2,则可能的交点数量为0(平行)或者1(不平行)。Input输入数据包含多个测试实例,每个测试实例占一行,每行包含一个正整数n(nOutput每个测试实例对应一行输出,从小到大列出所有相交方案,其中每个数为可能的交点数,每行的整数之间用一个空格隔开。原创 2016-07-17 22:20:06 · 197 阅读 · 0 评论 -
HDU 1493 QQpet exploratory park(概率DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1493题意:一排有61个格子标号0-60。其中停在5,12, 22, 29, 33, 38, 42, 46, 50,55上能得到奖励。从0号格子开始掷骰子到几点就走几步,一共只能掷十次,给出1-6点出现的概率,求停在这十个格子的概率。思路:dp[i][j]表示掷第j次后走到第i个原创 2016-07-17 23:32:48 · 739 阅读 · 0 评论 -
HDU 1494 跑跑卡丁车(简单DP)
Problem Description跑跑卡丁车是时下一款流行的网络休闲游戏,你可以在这虚拟的世界里体验驾驶的乐趣。这款游戏的特别之处是你可以通过漂移来获得一种加速卡,用这种加速卡可以在有限的时间里提高你的速度。为了使问题简单化,我们假设一个赛道分为L段,并且给你通过每段赛道的普通耗时Ai和用加速卡的耗时Bi。加速卡的获得机制是:普通行驶的情况下,每通过1段赛道,可以获得20%的能量(N2原创 2016-07-18 10:16:43 · 407 阅读 · 0 评论 -
HDU 5763 Another Meaning(KMP+DP)
Problem DescriptionAs is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”.Today, ?? is chating with MeiZi online, M原创 2016-07-29 20:01:05 · 235 阅读 · 0 评论 -
HDU 1505 City Game(DP)
Problem DescriptionBob is a strategy game programming specialist. In his new city building game the gaming environment is as follows: a city is built up by areas, in which there are streets, trees,f原创 2016-07-30 10:14:54 · 192 阅读 · 0 评论 -
HDU 5781 ATM Mechine(概率DP)
Problem DescriptionAlice is going to take all her savings out of the ATM(Automatic Teller Machine). Alice forget how many deposit she has, and this strange ATM doesn't support query deposit. The onl原创 2016-08-03 17:30:14 · 424 阅读 · 0 评论 -
UVA 1631 Locker(HDU 4433)(DP)
A password locker with N digits, each digit can be rotated to 0-9 circularly.You can rotate 1-3 consecutive digits up or down in one step.For examples:567890 → 567901 (by rotating the last 3 dig原创 2016-07-31 20:40:23 · 370 阅读 · 0 评论 -
HDU 1074 Doing Homework(状压DP+储存路径)
DescriptionIgnatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in the home原创 2016-05-01 21:17:24 · 305 阅读 · 0 评论