POJ 1239 Increasing Sequences 动态规划】的更多相关文章

题目链接: http://poj.org/problem?id=1239 Increasing Sequences Time Limit: 1000MSMemory Limit: 10000K 问题描述 Given a string of digits, insert commas to create a sequence of strictly increasing numbers so as to minimize the magnitude of the last number. For…
http://poj.org/problem?id=1239 题意:给出一串序列,现在要添加逗号作为分隔符,使得序列是递增序列,然后让最后一个数尽量小,第一个数尽量大. 思路:先从头到尾进行一次dp,d[i]表示分析到第i位时往前的最小长度,这样一来,d[n]就表示最后一位的最小长度. 在满足了最后一位尽量小的情况下,我们再从尾到头进行一次dp,此时d[i]表示分析到第i位时往后的最大长度.思路和第一次dp是差不多的. #include<iostream> #include<algori…
题意:略. 思路:进行两次dp. 第一次dp从前向后,用dp[x]表示从第x位向前dp[x]位可构成一个数字,且与前面的数组符合题意要求.最后求的dp[n]即为最后一个数字的长度. 而题目还有要求,所有解中输出前面数字最大的一个.因此还需要进行一次dp,从后向前. 具体看代码吧,当初也是看别人代码才看懂的. #include<stdio.h> #include<string.h> ]; ], n; bool judge(int st1,int len1,int st2,int le…
题目地址:http://poj.org/problem?id=2127 Description You are given two sequences of integer numbers. Write a program to determine their common increasing subsequence of maximal possible length. Sequence S1 , S2 , . . . , SN of length N is called an increa…
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1423 Problem Description This is a problem from ZOJ 2432.To make it easyer,you just need output the length of the subsequence.   Input Each sequence is described with M - its length (1 <= M <= 500) and…
http://poj.org/problem?id=1776 题意: 有一个机器要完成N个作业, 给你一个N*N的矩阵, M[i][j]=1,表示完成第i个作业后不用重启机器,继续去完成第j个作业 M[i][j]=0,表示如果做完第i个作业,想要继续去做第j个作业,那么必须重启机器 对于任意两个作业都有M[i][j] = 1或者M[j][i] = 1. 求出完成这N个作业启动机器的最少次数,以及每次启动完成作业的数量和这些作业的顺序 初始时机器处于关闭状态. 将M当做图,就是找最少的路径条数覆盖…
A. DZY Loves Sequences 题目连接: http://www.codeforces.com/contest/446/problem/A Description DZY has a sequence a, consisting of n integers. We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) d…
描述 Given a string of digits, insert commas to create a sequence of strictly increasing numbers so as to minimize the magnitude of the last number. For this problem, leading zeros are allowed in front of a number. 输入 Input will consist of multiple tes…
题目链接:http://poj.org/problem?id=3211 题意:有M件衣服,每种衣服有一种颜色,一共有N种颜色.现在两个人洗衣服,规则是必须把这一种颜色的衣服全部洗完才能去洗下一种颜色的衣服. 问:在两个人可以同时洗衣服的情况下,把衣服全部洗完最少需要多久. 如果说两个人同时洗同一种颜色衣服,那么最少的时间就是洗完该颜色衣服的总时间的一半. 那么我们可以将洗每种衣服分开来看,视作一个01背包,容量是洗该颜色衣服的总时间的一半. 然后最多花多久.那么该颜色的总时间-这个人花的最多时间…
题目地址:http://poj.org/problem?id=1661 Description "Help Jimmy" 是在下图所示的场景上完成的游戏. 场景中包括多个长度和高度各不相同的平台.地面是最低的平台,高度为零,长度无限. Jimmy老鼠在时刻0从高于所有平台的某处开始下落,它的下落速度始终为1米/秒.当Jimmy落到某个平台上时,游戏者选择让它向左还是向右跑,它跑动的速度也是1米/秒.当Jimmy跑到平台的边缘时,开始继续下落.Jimmy每次下落的高度不能超过MAX米,不…