dp
欧莎
啦啦啦,啦啦啦,让我们一起洗刷刷
展开
-
hdu 5735
点击打开链接http://acm.hdu.edu.cn/showproblem.php?pid=5735#include#include#include#includeusing namespace std;char opt[5];int op(int x,int y){ if(*opt == 'A') return x & y; if(*op原创 2016-07-28 10:49:20 · 318 阅读 · 0 评论 -
最长公共字串
牛客网的题目链接题目描述: 链接:https://www.nowcoder.com/questionTerminal/02e7cc263f8a49e8b1e1dc9c116f7602 来源:牛客网对于两个字符串,请设计一个时间复杂度为O(m*n)的算法(这里的m和n为两串的长度),求出两串的最长公共子串的长度。这里的最长公共子串的定义为两个序列U1,U2,..Un和V1,V2,…Vn,...原创 2018-03-15 11:13:15 · 193 阅读 · 0 评论 -
ZOJ Problem Set - 2319 Beautiful People
Time Limit: 5 Seconds Memory Limit: 32768 KB Special Judge The most prestigious sports club in one city has exactly N members. Each of its members is strong and beautiful. More precisely, i原创 2017-04-20 08:46:39 · 259 阅读 · 0 评论 -
hdu 1024 Max Sum Plus Plus(K个最大连续子序列和)
未优化的K个最大连续子序列和,时间复杂度O(n^3) ,动态转移方程 dp[i,j]=max{dp[i,j-1]+a[j],dp[i-1,k]+a[j]} (i-1<=k<=j-1)#include<iostream>using namespace std;int a[1001];int dp[11][1001];int main(){ int n,k,temp,Max;原创 2017-04-05 21:20:15 · 433 阅读 · 0 评论 -
FatMouse's Speed HDU - 1160(最长上升子序列及输出路径)
Problem Description FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as poss原创 2017-04-13 10:12:52 · 849 阅读 · 0 评论 -
求全1的最大正方形的边长 和 全1的最大子矩阵的面积 和POJ 2559 最大直方图
#include #include#include#include#include#include#include#define ll long long#define mem(a,b) memset(a,b,sizeof(a))using namespace std;int dir[4][2]= {{0,1},{1,0},{-1,0},{0,-1}};int mapp[10原创 2017-03-18 17:18:44 · 797 阅读 · 0 评论 -
hud 4722 Good Numbers(数位 DP)
Problem DescriptionIf we sum up every digit of a number and the result can be exactly divided by 10, we say this number is a good number.You are required to count the number of good numbers in the原创 2017-03-17 10:58:00 · 170 阅读 · 0 评论 -
数位DP模板
#includeint dp[10];int a[10];int dfs(int pos,int last){ if(!pos) return 1; if(!last&&dp[pos]) return dp[pos]; int len=last?a[pos]:9,i,ans=0; for(i=0; i<=len; i++) ans+=i==原创 2017-03-17 10:33:40 · 167 阅读 · 0 评论 -
hdu Tickets 1260 (简单DP)
Problem Description Jesus, what a great movie! Thousands of people are rushing to the cinema. However, this is really a tuff time for Joe who sells the film tickets. He is wandering when could he go b原创 2017-04-11 21:07:52 · 387 阅读 · 0 评论 -
最长单调递增子序列模板和 打印路径
#include const int N=100005; int main() { int n,a,len; int dp[N]; while(~scanf("%d",&n)) { len=0; dp[0]=-1; for(int i=0;i<n原创 2017-03-05 12:45:37 · 304 阅读 · 0 评论 -
hud 1074 Doing Homework(状态压缩)
Problem Description Ignatius 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 t原创 2017-04-07 14:02:16 · 280 阅读 · 0 评论 -
hud 1069 Monkey and Banana(最长不递减的子序列的应用)
Problem Description 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原创 2017-04-07 10:54:57 · 354 阅读 · 0 评论 -
田忌赛马 poj 2287 (贪心,动态规划,贪心+动态规划)
题目链接贪心 ;1:如果田忌的最快马快于齐王的最快马,比一场 2: 如果田忌的最快马慢于齐王的最快马,则用田忌的最慢马和齐王的最快马比赛一场 3: 如果田忌的最快马和齐王的最快马一样快,则比较田忌的最慢马和齐王的最慢马分两种情况 (1) 若田忌的最慢马快于齐王的最慢马,田忌的慢马和齐王的慢马进行比较原创 2017-03-20 21:33:27 · 2271 阅读 · 0 评论 -
hdu 2082 找单词(多重背包)
Problem Description假设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,..... 字母Z的价值为26。那么,对于给定的字母,可以找到多少价值 Input输入首先是一个整数N,代表测试实例的个数。然后包括N行数据,每行包括26个 Output对于每个测试实例,请输出能找原创 2016-11-15 21:26:00 · 349 阅读 · 0 评论 -
hdu 2084 数塔
Problem Description在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?已经告诉你了,这是个DP的题目,你能AC吗? Input输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N(1原创 2016-11-13 18:45:32 · 195 阅读 · 0 评论 -
hdu 5763 Another Meaning(2016多校联赛)
http://acm.hdu.edu.cn/showproblem.php?pid=5763题目的意思是,给两个字符串a,b,其中b串有两种意思,如果b是a的子串问a串表达几种意思,其中的“hehe”的 号表示的是b串 。 思路:我在比赛的时候做的时候,知道用KMP,但是呢,不知道中间的该怎么办,我就试着需找规律,但是规律我找的还是错的,后来,比赛结束后就看的题解,理解后,自己打出来的,但是呢,因原创 2016-07-29 17:31:54 · 289 阅读 · 0 评论