Dynamic programming
文章平均质量分 77
IR1S
这个作者很懒,什么都没留下…
展开
-
动态规划之递推之CF 429B B.Working out
PROBLEMS SUBMIT STATUS STANDINGS CUSTOM TESTB. Working outtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSummer is com...原创 2018-08-01 10:25:44 · 280 阅读 · 2 评论 -
欧拉筛
#include<iostream>using namespace std;#define MAX 10000int flag[MAX];int prime[MAX];int primesize = 0;int min_prime[MAX];void getprime(int n)//n以内的素数{ for (int i = 2; i <= n; ++i...原创 2018-02-25 13:44:04 · 136 阅读 · 0 评论 -
用费马小定理判断素数
#include<iostream>#include<cstdlib>#include<ctime>using namespace std;long long modular_power(long long a, long long n, long long p)//a^m%p{ if (n == 0) return 1; if (n == ...原创 2018-02-25 13:31:03 · 1036 阅读 · 0 评论 -
动态规划22 Employment Planning
Employment PlanningTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 48 Accepted Submission(s) : 23Font: Times New Roman | Verdana | G原创 2018-01-30 12:49:37 · 230 阅读 · 0 评论 -
动态规划21 fast food
Fast FoodTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 69 Accepted Submission(s) : 26Font: Times New Roman | Verdana | Georgia原创 2018-01-30 12:27:59 · 445 阅读 · 0 评论 -
动态规划19 计算直线交点数
计算直线的交点数Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 20 Accepted Submission(s) : 12Font: Times New Roman | Verdana | GeorgiaF原创 2018-01-30 12:06:42 · 422 阅读 · 0 评论 -
动态规划18 丑数问题
Humble NumbersTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 29 Accepted Submission(s) : 13Font: Times New Roman | Verdana | Georgi原创 2018-01-30 11:58:25 · 507 阅读 · 0 评论 -
cf B. Appleman and Tree 树形DP
Appleman and TreeAppleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.Consider a set consisting of k (0 ≤ k < n) edges...原创 2018-08-07 11:10:04 · 395 阅读 · 0 评论 -
百度之星A题 调查问卷
调查问卷Accepts: 1546Submissions: 6596Time Limit: 6500/6000 MS (Java/Others)Memory Limit: 262144/262144 K (Java/Others)Problem Description度度熊为了完成毕业论文,需要收集一些数据来支撑他的论据,于是设计了一份包含 mmm 个问题的调查问卷,每个问...原创 2018-08-07 14:43:50 · 204 阅读 · 0 评论 -
zoj4027 dp
题目链接:https://vjudge.net/contest/266104#problem/D题目意思:一个含有左右括号的字符串,每个左右括号都有一个值,字符串中的()能够交换,并且一旦交换,ans+=两个括号值的乘积,求最大ans题目思路:很明显,每个(能够一直右移到她右边的第一个(之前,一开始想到的暴力枚举,但是显然不行,后来想到了dp 定义d...原创 2018-11-06 12:40:35 · 236 阅读 · 0 评论 -
2018 ACM-ICPC 焦作 K. Transport Ship 母函数
题目链接:https://nanti.jisuanke.com/t/31720 题目思路:乍一看很吓人而已,一开始自己还在想组合数学,发现自己傻逼了,题目中x^c[i]-1,提示很明确要将船分解成1,2,4,8,16,然后就想到是所有船分解成1,2,4,8,16……,然后能和为S的就能用母函数求法求出,复杂度是20(T)*20(N)*20(C[I])*10000(S),不会超时 A...原创 2018-09-17 18:02:12 · 172 阅读 · 0 评论 -
2018 ACM-ICPC 焦作赛区 B Transport Ship 简单递推
题目链接:https://nanti.jisuanke.com/t/31720 题目思路:首先我想到了用dp1[i][j]来表示前i个数字用j个符号能表示出来的最大值,以及用dp2[i][j]来表示用前i个数字用j个符号能表示出来的最小值,可是我接下来想的使用dfs(int ,a,int b,int c,int d),分别表示a个数字用b个符号能表示的最小值c,最大值d,然后如果(c>...原创 2018-09-17 17:49:17 · 189 阅读 · 0 评论 -
CCPC 2018 网络赛 1010 YJJ's Salesman
http://acm.hdu.edu.cn/showproblem.php?pid=6447 YJJ's Salesman Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1330 Accepted Submi...原创 2018-08-27 15:30:25 · 182 阅读 · 0 评论 -
CF 505 D. Recovering BST 区间DP
D. Recovering BSTtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDima the hamster enjoys nibbling different things: cages, sticks...原创 2018-08-22 10:47:56 · 241 阅读 · 0 评论 -
树形dp 1509: [NOI2003]逃学的小孩
1509: [NOI2003]逃学的小孩Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 968 Solved: 489[Submit][Status][Discuss]DescriptionInput第一行是两个整数N(3 N 200000)和M,分别表示居住点总数和街道总数。以下M行,每行给出一条街道的信息。第i+1行...原创 2018-08-16 14:52:10 · 194 阅读 · 0 评论 -
Codeforces 337D Book of Evil
D. Book of Eviltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPaladin Manao caught the trail of the ancient Book of Evil in a s...原创 2018-08-03 13:02:56 · 225 阅读 · 0 评论 -
动态规划17 Free DIY Tour
Free DIY TourTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 40 Accepted Submission(s) : 12Font: Times New Roman | Verdana | Georgia原创 2018-01-30 11:49:50 · 172 阅读 · 0 评论 -
动态规划16 免费馅饼(数塔问题)
免费馅饼Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 78 Accepted Submission(s) : 25Font: Times New Roman | Verdana | GeorgiaFont原创 2018-01-30 11:47:25 · 442 阅读 · 0 评论 -
动态规划之最长递增子序列
//O(Nlogn)算法//同样a,dp两个数组,a中存放序列的每个值//dp[i]指长度为i的序列中最后一个值的最小值,例如有两个相同长度的序列1,3,6和1,3,4则dp[3] = 4;//有两种算法//dp中全为最大值INT_MAX时for (int i = 1; i <= n; ++i){ int pos = lower_bound(dp + 1, dp + 1 + n,a[原创 2018-01-28 16:00:40 · 242 阅读 · 0 评论 -
动态规划10array array array
array array arrayTime Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 39 Accepted Submission(s) : 12Font: Times New Roman | Verdana | Geo原创 2018-01-28 15:13:15 · 182 阅读 · 0 评论 -
动态规划9Monkey and Banana
Monkey and BananaTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 24 Accepted Submission(s) : 13Font: Times New Roman | Verdana | Geo原创 2018-01-28 14:59:19 · 201 阅读 · 0 评论 -
动态规划7最大子矩阵
To The MaxTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 22 Accepted Submission(s) : 17Font: Times New Roman | Verdana | Georgia原创 2018-01-28 14:49:34 · 141 阅读 · 0 评论 -
动态规划8FatMouse's Speed
FatMouse's SpeedTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 27 Accepted Submission(s) : 13Special JudgeFont: Times New Roman原创 2018-01-28 14:54:13 · 299 阅读 · 0 评论 -
动态规划6Max Sum Plus Plus
Max Sum Plus PlusTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 35 Accepted Submission(s) : 18Font: Times New Roman | Verdana | Geo原创 2018-01-28 14:46:11 · 181 阅读 · 0 评论 -
动态规划5Max Sum
Max SumTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 91 Accepted Submission(s) : 23Font: Times New Roman | Verdana | GeorgiaFo原创 2018-01-28 14:44:34 · 217 阅读 · 0 评论 -
组合数学之母函数
//老版母函数//首先用c1,c2两个数组,c1[j]表示j块钱有c1[j]中表达方式//c1[0]=1,c2 0//关键for循环for (int i = 0; i < n; ++i)//该循环是指每*种*货币一个个的放进去,共n种{ for (int j = 0; j <= p; ++j)//这里是c1数组的循环,c1的数组界p { for (int k = 0; k <=原创 2018-01-27 21:44:33 · 263 阅读 · 0 评论 -
动态规划11最长公共子序列
Common SubsequenceTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 72 Accepted Submission(s) : 30Font: Times New Roman | Verdana | Ge原创 2018-01-28 16:07:07 · 163 阅读 · 0 评论 -
动态规划12最长公共子序列
Advanced FruitsTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 33 Accepted Submission(s) : 13Special JudgeFont: Times New Roman原创 2018-01-28 16:08:54 · 186 阅读 · 0 评论 -
动态规划15 数塔
数塔Time Limit : 1000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 35 Accepted Submission(s) : 25Font: Times New Roman | Verdana | GeorgiaFont Si原创 2018-01-30 11:44:09 · 189 阅读 · 0 评论 -
动态规划14 Zipper
ZipperTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 30 Accepted Submission(s) : 13Font: Times New Roman | Verdana | GeorgiaFon原创 2018-01-30 11:42:15 · 208 阅读 · 0 评论 -
动态规划之01背包,完全背包,分组背包
一:01背包每样物品只能取一件状态转移方程 f[i][v]=max(f[i-1][v],f[i-1][v-weight[i]]+cost[i])f[i][v]表示前i件物品装入v的空间里的最大价值,考虑第i件物品是否放入的问题,一种是不放入那就是前i-1件物品放入v中,另一种考虑放入则是前i-1件物品放入v-weight[i]空间的最大值将空间缩减成VNfor (int i =原创 2018-01-20 19:14:58 · 365 阅读 · 0 评论 -
动态规划4
DividingTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 48 Accepted Submission(s) : 12Font: Times New Roman | Verdana | GeorgiaF原创 2018-01-20 15:52:39 · 187 阅读 · 0 评论 -
动态规划3
Piggy-BankTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 40 Accepted Submission(s) : 14Font: Times New Roman | Verdana | Georgia原创 2018-01-20 15:44:20 · 149 阅读 · 0 评论 -
动态规划2
FATETime Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 45 Accepted Submission(s) : 17Font: Times New Roman | Verdana | GeorgiaFont原创 2018-01-20 15:28:49 · 116 阅读 · 0 评论 -
动态规划1
最大报销额Time Limit : 1000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 49 Accepted Submission(s) : 15Font: Times New Roman | Verdana | GeorgiaFont原创 2018-01-20 15:21:59 · 241 阅读 · 0 评论 -
动态规划13 Human Gene Functions
Human Gene FunctionsTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 20 Accepted Submission(s) : 14Font: Times New Roman | Verdana |原创 2018-01-28 16:10:31 · 320 阅读 · 0 评论 -
codeforces 360B dp+二分
题目链接:http://codeforces.com/problemset/problem/360/B题目含义:给定n个数,你可以修改k个数,是他们中任意两个相邻的数的差值的绝对值最小,求出那个最小值题目思路:将答案二分, dp[i]表示第i个数字不变并且前i个数字中任意两个相邻数字的差值的绝对值小于等于二分答案所需要改变数的个数,状态转移方程对于j<i并且abs(num...原创 2019-05-16 15:44:06 · 426 阅读 · 0 评论