动态规划
Lbbbbpro029
这个作者很懒,什么都没留下…
展开
-
HDU 5328 Problem Killer(简单DP)
大意: 输出其中最长的等差(AP)或等比(GP)数列的长度。 数列长度为1或2时一定是等比或等差数列。 如果a,b,c是AP或GP,b,c,d是AP或GP那么a,b,c,d是AP或GP。 因此有状态转移方程。#include #include #include #include #define eps 1e-6; using namespace std; int a[100000原创 2015-08-13 14:31:46 · 308 阅读 · 0 评论 -
(从头做DP)HDU 1025 Constructing Roads In JGShining's Kingdom
最长上升子序列的nlogn算法。 #include #include using namespace std; int a[500005],ans[500005]; int main() { ios::sync_with_stdio(false); int n,x,y,d=1; while(cin>>n) { for(int i=0;i<n;原创 2015-10-21 14:38:01 · 211 阅读 · 0 评论 -
(从头做DP)HDU 1003 Max Sum
#include using namespace std; int main() { int T,n,x,d=1; cin>>T; //int a[1000005]; while(T--) { cin>>n; int maxsum=-1001,sum=0,st=0,en=0,t=0; for(int i原创 2015-10-21 14:35:37 · 229 阅读 · 0 评论 -
(从头写DP)HDU 1058 Humble Numbers
状态转移方程 a[i]=min(2*a[b2],3*a[b3],5*a[b5],7*a[b7]). 注意序数词的结尾。 #include #include using namespace std; int a[500005],ans[500005]; int main() { ios::sync_with_stdio(false); int n; a[1]=1;原创 2015-10-21 14:41:58 · 232 阅读 · 0 评论 -
20161005 弱校联萌10.5 H Hash Collision(二分+FFT+dp)
本来不咋爱写博客的,但是这题实在让我受益匪浅,所以记录一下。 = = 题目大意是求所有长度为n的只含大写字母的字符串按所给函数进行hash,hash值有多少对相同,结果mod1e6+3。 思路: 刚开始想到用所给的hash函数进行dp,,即记录到第i个字符hash值为j的个数用26个字母递推到第i+1个字符对应的hash值,加上dp(i,j),是但是考虑了下复杂度是O原创 2016-10-05 20:34:54 · 460 阅读 · 0 评论