dp
凌晨四点的洛杉矶fly
这个作者很懒,什么都没留下…
展开
-
牛客练习赛53:A(简单dp)
链接:https://ac.nowcoder.com/acm/contest/1114/A来源:牛客网题目描述超越学姐非常喜欢自己的名字,以至于英文字母她只喜欢“c”和“y”。因此超越学姐喜欢只含有“c”和“y”的字符串,且字符串中不能出现两个连续的“c”。请你求出有多少种长度为n的字符串是超越学姐喜欢的字符串。答案对1e9+7取模。输入描述:链接:https://ac.no...原创 2019-10-15 10:06:22 · 125 阅读 · 0 评论 -
E - キャンディーとN人の子供 / Children and Candies(dp+前缀和优化)
Problem Statement12:17 (UTC): The sample input 1 and 2 were swapped. The error is now fixed. We are very sorry for your inconvenience.There areNNchildren in AtCoder Kindergarten, conveniently nu...原创 2019-05-16 19:07:20 · 227 阅读 · 0 评论 -
C - 高橋君とカード / Tak and Cards(dp)
Problem StatementTak hasNNcards. On theii-th(1≤i≤N)(1≤i≤N)card is written an integerxixi. He is selecting one or more cards from theseNNcards, so that the average of the integers written on ...原创 2019-05-16 20:59:11 · 196 阅读 · 0 评论 -
牛客910/B(背包)
链接:https://ac.nowcoder.com/acm/contest/910/B来源:牛客网现有N元钱,兑换成小额的零钱,有多少种换法?币值包括1 2 5分,1 2 5角,1 2 5 10 20 50 100元。(由于结果可能会很大,输出Mod 10^9 + 7的结果)输入输入描述:第一行输入一个整数T,代表有T组数据接下来T行,每行输入1个数N,N = 10...原创 2019-05-26 19:41:35 · 145 阅读 · 0 评论 -
E - 高橋君とホテル / Tak and Hotels(dp+倍增)
题目链接:https://atcoder.jp/contests/arc060/tasks/arc060_cProblem StatementNNhotels are located on a straight line. The coordinate of theii-th hotel(1≤i≤N)(1≤i≤N)isxixi.Tak the traveler has the...原创 2019-05-17 22:45:32 · 200 阅读 · 0 评论 -
E - 和風いろはちゃん / Iroha and Haiku(dp+状压)
Problem StatementHaiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.Iroha is looking forX,Y,ZX,Y,Z-Haiku(defined below) in integ...原创 2019-05-18 13:06:50 · 3542 阅读 · 0 评论 -
D - No Need(传递dp)
Problem StatementAtCoDeer the deer hasNNcards with positive integers written on them. The number on theii-th card(1≤i≤N)(1≤i≤N)isaiai. Because he loves big numbers, he calls a subset of the ca...原创 2019-06-01 21:20:54 · 272 阅读 · 0 评论 -
poj2229(dp)
Farmer John commanded his cows to search for different sets of numbers that sum to a given number. The cows use only numbers that are an integer power of 2. Here are the possible sets of numbers that ...原创 2019-06-08 21:14:20 · 82 阅读 · 0 评论 -
四维dp
链接:https://ac.nowcoder.com/acm/contest/1072/A来源:牛客网题目描述设有N*N的方格图(N ≤ 10,我们将其中的某些方格中填入正整数,而其他的方格中则放入数字0。如下图所示(见样例):某人从图的左上角的A 点出发,可以向下行走,也可以向右走,直到到达右下角的B点。在走过的路上,他可以取走方格中的数(取走后的方格中将变为数字0)。此...原创 2019-09-03 10:44:26 · 372 阅读 · 1 评论 -
牛客696D
链接:https://ac.nowcoder.com/acm/contest/696/D来源:牛客网小K有n个雕塑,每个雕塑上有一个整数若集合T中的每一个元素在n个雕塑上都能找得到,则称这个集合为一个优秀的集合小K想知道所有大小<=k优秀的集合的价值和是多少一个优秀的集合的价值可以用F(T)=∏x∈TxF(T)=∏x∈Tx来表示特别的F(∅)=1, |∅|=0即求...原创 2019-05-02 10:09:18 · 162 阅读 · 0 评论 -
zoj4019 dp
DreamGrid has a magical knapsack with a size capacity ofcalled the Schrödinger's knapsack (or S-knapsack for short) and two types of magical items called the Schrödinger's items (or S-items for shor...原创 2019-04-25 19:20:51 · 76 阅读 · 0 评论 -
hdu 2191多重背包
Input 输入数据首先包含一个正整数C,表示有C组测试用例,每组测试用例的第一行是两个整数n和m(1<=n<=100, 1<=m<=100),分别表示经费的金额和大米的种类,然后是m行数据,每行包含3个数p,h和c(1<=p<=20,1<=h<=200,1<=c<=20),分别表示每袋的价格、每袋的重量以及对应种类大米的袋数。Ou...原创 2018-09-24 14:03:19 · 566 阅读 · 0 评论 -
hdu6333 组合数加莫队,n个苹果最多取m个,求方案数。
题解: 令表示n个苹果最多取m个的方案数,很容易想到 根据杨辉三角也很容易推出 我们将m-n当作一条线段,那么就是这条线段的函数值,而根据上面的两个公式,又可以在O(1)的时间内实现到、、、的转移。利用莫队算法离线处理即可。代码:#include<bits/stdc++.h>#define INF 0x3f3f3f3f#define IO ios::sync_with_s...原创 2018-09-24 14:11:20 · 137 阅读 · 0 评论 -
数位dp
Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of the number on even positions and nowhere else.For example, the numbers 1727...原创 2019-01-17 10:48:54 · 324 阅读 · 0 评论 -
hdu1561树形dp+01背包
ACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡。你能帮ACboy算出要获得尽量多的宝物应该攻克哪M个城堡吗? Input每个测试实例首先包括2个整数,N,M.(1 <= M <= N <= 200...原创 2019-01-23 20:56:04 · 122 阅读 · 0 评论 -
dp
链接:https://ac.nowcoder.com/acm/contest/327/G来源:牛客网 题目描述一天,处女座在牛客算法群里发了一句“我好强啊”,引起无数的复读,可是处女座发现复读之后变成了“处女座好强啊”。处女座经过调查发现群里的复读机都是失真的复读机,会固定的产生两个错误。一个错误可以是下面的形式之一:1. 将任意一个小写字母替换成另外一个小写字母2...原创 2019-01-24 19:53:00 · 134 阅读 · 0 评论 -
dp找路径的最大值
Problem Description度度熊是一只喜欢探险的熊,一次偶然落进了一个m*n矩阵的迷宫,该迷宫只能从矩阵左上角第一个方格开始走,只有走到右上角的第一个格子才算走出迷宫,每一次只能走一格,且只能向上向下向右走以前没有走过的格子,每一个格子中都有一些金币(或正或负,有可能遇到强盗拦路抢劫,度度熊身上金币可以为负,需要给强盗写欠条),度度熊刚开始时身上金币数为0,问度度熊走出迷宫时候身上...原创 2019-01-14 21:23:02 · 354 阅读 · 0 评论 -
poj1475
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 us,...原创 2019-03-15 21:02:10 · 113 阅读 · 0 评论 -
UVA - 12034 (dp)
Disky and Sooma, two of the biggest mega minds of Bangladesh went to a far country. They ate, coded and wandered around, even in their holidays. They passed several months in this way. But everything ...原创 2019-03-26 15:54:08 · 116 阅读 · 0 评论 -
没有上司的舞会
Description Ural大学有N个职员,编号为1~N。他们有从属关系,也就是说他们的关系就像一棵以校长为根的树,父结点就是子结点的直接上司。每个职员有一个快乐指数。现在有个周年庆宴会,要求与会职员的快乐指数最大。但是,没有职员愿和直接上司一起与会。Input第一行一个整数N。(1<=N<=6000)接下来N行,第i+1行表示i号职员的快乐指数Ri。(-1...原创 2018-08-26 20:00:41 · 66 阅读 · 0 评论