dp--计数dp&方案数&组合数学加dp
ccsu_deer
这个作者很懒,什么都没留下…
展开
-
牛客OI周赛15-普及组(C区间加 dp)
题目链接官方题解:学到了。#include<bits/stdc++.h>#define rep(i,a,b) for(int i=a;i<=(b);++i)#define mem(a,x) memset(a,x,sizeof(a))#define pb push_back#define pi pair<int, int>#defin...原创 2020-04-04 17:12:37 · 390 阅读 · 0 评论 -
D2. RGB Substring (hard version)(动态规划)
【题目】time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between easy and hard versions is the size of the input....原创 2019-07-25 10:38:34 · 396 阅读 · 0 评论 -
D. Gargari and Permutations(dp 几组数据)
D. Gargari and Permutationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGargari got bored to play with the bishops and now, a...原创 2019-03-19 21:52:38 · 366 阅读 · 0 评论 -
G-免费馅饼(HDU - 1176 )(移动接馅饼最大值)
都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个身手敏捷的高手,但在现实中运动神经特别迟钝...原创 2019-02-27 10:20:31 · 341 阅读 · 0 评论 -
UVA11400照明系统设计(较为复杂的动态规划问题)
题目如下: You are given the task to design a lighting system for a huge conference hall. After doing a lot of calculation and sketching, you have figured out the requirements for an energy-efficient des...原创 2019-02-25 21:38:52 · 353 阅读 · 0 评论 -
uva116 TSP(多阶段决策 入门)
BackgroundProblems that require minimum paths through some domain appear in many different areas of computer science. For example, one of the constraints in VLSI routing problems is minimizing wire l...原创 2019-01-17 17:24:19 · 899 阅读 · 0 评论 -
小乐乐下象棋(记忆化搜索)
链接:https://ac.nowcoder.com/acm/contest/301/F来源:牛客网 小乐乐一天天就知道玩,这一天又想玩象棋。我们都知道马走日。现在给定一个棋盘,大小是n*m,把棋盘放在第一象限,棋盘的左下角是(0,0),右上角是(n - 1, m - 1);小乐乐想知道,一个马从左下角(0, 0)开始,走了k步之后,刚好走到右上角(n - 1, m - 1)的方案数...原创 2018-12-27 19:48:49 · 342 阅读 · 2 评论 -
dp求最长上升子序列
二分法:#include<cstdio>#include<algorithm>using namespace std;const int maxn=2e5+10;int a[maxn];int dp[maxn]; int main(){ int n; while(~scanf("%d",&n)) { for(i...原创 2018-12-26 19:26:39 · 348 阅读 · 0 评论 -
16-矩形嵌套(有向无环图上的DP)(建图做法和直接DP做法)
16-矩形嵌套 内存限制:64MB 时间限制:3000ms 特判: No 通过数:53 提交数:136 难度:4 题目描述:有n个矩形,每个矩形可以用a,b来描述,表示长和宽。矩形X(a,b)可以嵌套在矩形Y(c,d)中当且仅当a<c,b<d或者b<c,a<d(相当于旋转X90度)。例如(1,5)可以嵌套在(6,2)内,但不能嵌套在(3,4)中。你...原创 2018-12-17 08:48:13 · 394 阅读 · 0 评论 -
1091-还是01背包(较为复杂的01背包变形)
1091-还是01背包 内存限制:223MB 时间限制:10000ms 特判: No 通过数:1 提交数:1 难度:5 题目描述:有n个重量和价值分别为 wi 和 vi 的物品,从这些物品中挑选总重量不超过W的物品,求所有挑选方案中价值总和的最大值。输入描述:多组测试数据。每组测试数据第一行输入n 和 W ,接下来有n行,每行输入两个数,代表第i个物品的wi ...原创 2018-12-16 19:56:34 · 328 阅读 · 0 评论 -
最少硬币问题(动态规划递推式)
最少硬币问题时间限制(普通/Java) : 1000 MS/ 3000 MS 运行内存限制 : 65536 KByte总提交 : 247 测试通过 : 73 比赛描述设有n种不同面值的硬币,各硬币的面值存于数组T[1:n]中。现要用这些面值的硬币来找钱。可以使用的各种面值的硬币个数存于数组Coins[1:n]中。对任意钱数0≤m≤20001,设计...原创 2018-12-03 17:09:38 · 2171 阅读 · 0 评论 -
数字三角形问题(动态规划入门)
最近在刷动态规划类的题,刷紫书的259页题题目来源:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/1730.html数字三角形问题Time Limit: 1000 ms Memory Limit: 65536 KiBSubmit Statistic DiscussProble...原创 2018-12-03 16:59:40 · 400 阅读 · 0 评论 -
ZOJ Problem Set - 4045 District Division(树 切割成份)
Ezio learned a lot from his uncle Mario in Villa Auditore. He also made some contribution to Villa Auditore. One of the contribution is dividing it into many small districts for convenience of managem...原创 2018-07-22 14:26:14 · 335 阅读 · 0 评论 -
j - 分组(动态规划)
链接:https://ac.nowcoder.com/acm/contest/918/J来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述在Farmer John最喜欢的节日里,他想要给他的朋友们赠送一些礼物。由于他并不擅长包装礼物,他想要获得他的奶牛们的帮助。你...原创 2019-06-17 16:00:36 · 522 阅读 · 0 评论 -
E. Cashback(每分割c长度子序列 可去掉最小的一个)
http://codeforces.com/problemset/problem/940/Etime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSince you are the best Wraith King...原创 2019-06-10 16:55:51 · 406 阅读 · 0 评论 -
E - Super Jumping! Jumping! Jumping! (动态规划入门)
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.The game ...原创 2019-02-27 15:55:04 · 515 阅读 · 0 评论 -
C - Monkey and Banana (动态规划问题)
A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monk...原创 2019-02-27 14:59:00 · 521 阅读 · 0 评论 -
简单计数(递推式 矩阵快速幂加速)
链接:https://ac.nowcoder.com/acm/contest/879/A来源:牛客网简单计数时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述thewindandrainisinmywayandnevergoingawaythewindandrainisi...原创 2019-05-30 17:08:35 · 638 阅读 · 0 评论 -
666-RPG(计数dp入门)
链接:https://ac.nowcoder.com/acm/contest/373/B来源:牛客网lililalala正在玩一种有NN个回合的回合制RPG游戏,初始分数为0,第ii个回合lililalala有如下两种选择。 A.将分数加上aiai B.将分数×-1×-1lililalala同样也很讨厌野兽数666666,但是他很却喜欢数字-6...原创 2019-03-02 10:50:25 · 632 阅读 · 0 评论 -
牛客训练赛40(A 连续三个不能出现指定符号 计数dp)和C题树最大距离求法)
链接:https://ac.nowcoder.com/acm/contest/369/A来源:牛客网题目描述若你摘得小的星星 你将得到小的幸福若你摘得大的星星 你将得到大的财富若两者都能摘得 你将得到永远的愿望摘星是罪孽的宽恕 摘星是夜晚的奇迹抓住它吧 你所期望的那颗星无法触及,因而耀眼明明触及了,却还是耀眼——《少女☆歌剧 Revue·...原创 2019-02-19 14:03:06 · 398 阅读 · 0 评论 -
C. Ayoub and Lost Array(div 533 计数dp递推)
http://codeforces.com/contest/1105/problem/CC. Ayoub and Lost Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAyoub had an...原创 2019-01-22 10:32:24 · 408 阅读 · 0 评论 -
美丽序列(动态规划入门级别)
链接:https://ac.nowcoder.com/acm/problem/21313来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述牛牛喜欢整数序列,他认为一个序列美丽的定义是1:每个数都在0到40之间2:每个数都小于等于之前的数的平均值具体地说...原创 2019-06-22 23:15:05 · 1241 阅读 · 0 评论 -
codeforces(排序加动态规划)
链接:https://ac.nowcoder.com/acm/problem/21314来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述牛牛正在打一场CF比赛时间为T分钟,有N道题,可以在比赛时间内的任意时间提交代码第i道题的分数为maxPoints[i],题目...原创 2019-06-23 10:11:16 · 608 阅读 · 0 评论 -
Problem D Count The Bits (dp计算k的倍数中二进制1的个数)
Problem D Count The BitsGiven an integer k and a number of bits b (1 ≤ b ≤ 128), calculate the total number of 1 bits in the binary representations of multiples of k between 0 and 2b − 1 (inclusive)...原创 2019-07-05 10:30:48 · 592 阅读 · 0 评论 -
2019 杭电暑假多校训练 Distribution of books(线段树+dp)
Time Limit: 8000/8000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 411Accepted Submission(s): 135Problem Descriptionzz6d likes reading very much, so ...原创 2019-07-30 11:47:33 · 324 阅读 · 0 评论 -
D. Yet Another Subarray Problem( dp)
【题意】给定n、m、kn个数a[i]让你任选一个区间,使得最大。【题解】dp即可,设dp[i]为前i能得到的最大答案,由于m的范围比较小,只需要向前回溯m个寻找答案即可,每次区间和-k,那么r-l+1>=2就会自然的叠加了,类似01背包【代码】#include<bits/stdc++.h>using namespace std;typedef l...原创 2019-07-23 09:46:40 · 391 阅读 · 3 评论 -
被3整除的子序列(线性dp或者区间dp)
链接:https://ac.nowcoder.com/acm/problem/21302来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述给你一个长度为50的数字串,问你有多少个子序列构成的数字可以被3整除答案对1e9+7取模输入描述:输入一个字符串,...原创 2019-06-21 16:12:09 · 464 阅读 · 0 评论