USACO1.6 Number Triangles [dp-简单dp]】的更多相关文章

题目传送门 回忆童年 /* ID: Starry21 LANG: C++ TASK: ariprog */ #include<iostream> #include<string> #include<cstdio> #include<cstring> #include<vector> #include<algorithm> using namespace std; #define N 1005 #define ll long long…
题目大意: ...就是数塔       7         3   8      8   1   0     2   7   4   4 4   5   2   6   5 7+3+8+7+5=30 Sample Input 573 88 1 02 7 4 44 5 2 6 5 212 3 Sample Output 304 DP水题 记录一下 自下往上走 左右始终选择较大的与之上的相加 #include<iostream> #include<algorithm> #include…
P1216 [IOI1994][USACO1.5]数字三角形 Number Triangles 这个题吧,之前学DP的时候就做过一次了,其实还是挺简单的,如果一步一步按照找状态定义,找边界条件,找转移方程的话,不失为一道好题,我们就就这题复习一下DP,然后顺便讲点别的 因为我们是从顶点开始走,往左下走或者右下走,所以我们的状态就是F[i][j]我们停在第i行第j列所能达到的最大权值 对于每一个点,我们看他是从哪一个点过来的,可以是右上面也可以是左上面 转移方程:f[i][j]=max(f[i-1…
P1216 [USACO1.5]数字三角形 Number Triangles 题目描述 观察下面的数字金字塔. 写一个程序来查找从最高点到底部任意处结束的路径,使路径经过数字的和最大.每一步可以走到左下方的点也可以到达右下方的点. 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 在上面的样例中,从7 到 3 到 8 到 7 到 5 的路径产生了最大 输入输出格式 输入格式: 第一个行包含 R(1<= R<=1000) ,表示行的数目. 后面每行为这个数字金字塔特定行包含的整数. 所…
Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/attachments Description Noura Boubou is a Syrian volunteer at ACM ACPC (Arab Collegiate Programming Contest) since 2011. She graduated from Tishreen Un…
J - 简单dp Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description It is a little known fact that cows love apples. Farmer John has two apple trees (which are conveni…
转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://poj.org/problem?id=1163 --------------------------------------------------------------------------------------------------------------------------------------…
D. Fedor and Essay time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output After you had helped Fedor to find friends in the «Call of Soldiers 3» game, he stopped studying completely. Today, the E…
题目链接:http://codeforces.com/problemset/problem/1108/D time limit per test 1 secondmemory limit per test 256 megabytesinput standard inputoutput standard output You have a garland consisting of n lamps. Each lamp is colored red, green or blue. The colo…
(如此多的标签qaq) 数字三角形 Number Triangles[传送门] 本来打算当DP练的,没想到写着写着成递推了(汗) 好的没有时间了,我们附个ac代码(改天不写): #include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> #include<cmath> using namespace std; in…
C. Writing Code Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/544/problem/C Description Programmers working on a large project have just received a task to write exactly m lines of code. There are n programmers working o…
Kattis - bank [简单DP] Description Oliver is a manager of a bank near KTH and wants to close soon. There are many people standing in the queue wanting to put cash into their accounts after they heard that the bank increased the interest rates by 42% (f…
HDOJ 1501 Zipper [简单DP] Problem Description Given three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitrarily, but each must stay in i…
C. Dasha and Password time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password i…
F Fighting for Triangles Description Andy and Ralph are playing a two-player game on a triangular board that looks like the following: 1 234 5 7 86 910 11 13 14 16 1712 15 18 At each turn, a player must choose two adjacent vertices and draw a line se…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5375 题面: Gray code Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 626    Accepted Submission(s): 369 Problem Description The reflected binary cod…
免费馅饼 Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 102   Accepted Submission(s) : 35 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description 都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,…
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 33384    Accepted Submission(s): 15093 Problem Description Nowadays, a kind of chess game called “Super Jumping!…
Max Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the m…
Fibonacci String Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4568    Accepted Submission(s): 1540 Problem Description After little Jim learned Fibonacci Number in the class , he was very int…
题目链接:http://codeforces.com/problemset/problem/455/A 给你n个数,要是其中取一个大小为x的数,那x+1和x-1都不能取了,问你最后取完最大的和是多少. 简单dp,dp[i]表示取i时zui最大和为多少,方程为dp[i] = max(dp[i - 1] , dp[i - 2] + cont[i]*i). #include <bits/stdc++.h> using namespace std; typedef __int64 LL; ; LL a…
dp[i][j]代表以s[i][j]字符为右上角的最大对称方阵的尺寸 最左边那一列都为1,然后按列更新,代码实现比较简单,感觉有点卡时间,如果对称度很好,时间应该比较高,我只会这种了 #include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<algorithm> #include<cstring> #include<cstring…
Problem Description 俗话说一分钱难倒英雄汉,高中几年下来,吉哥已经深深明白了这个道理,因此,新年开始存储一年的个人资金已经成了习惯,不过自从大学之后他不好意思再向大人要压岁钱了,只能把唯一的希望放到自己身上.可是由于时间段的特殊性和自己能力的因素,只能找到些零零碎碎的工作,吉哥想知道怎么安排自己的假期才能获得最多的工资. 已知吉哥一共有m天的假期,每天的编号从1到m,一共有n份可以做的工作,每份工作都知道起始时间s,终止时间e和对应的工资c,每份工作的起始和终止时间以天为单位…
题目链接 这道题也是简单dp里面的一种经典类型,递推式就是dp[i] = min(dp[i-150], dp[i-200], dp[i-350]) 代码如下: #include<iostream> #include <stdio.h> using namespace std; ]; int main() { ; i < ; i++) dp[i] = i; ; i < ; i++) { int minn; ) dp[i] = dp[i - ]; ) dp[i] = min…
I - 简单dp 例题扩展 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HD…
题目链接 题意:你现在分数为a,对方分数为b,你比赛还有n分钟,每次进攻需要15分钟,现在你先进攻,每次进攻可以得1或2或3,对方每次进攻得一分,问超过对方分数有多少种打法 思路:因为情况太多要用__int64,很简单的dp,dp[n][m],n为第几次进攻,m为得分 #include <iostream> #include<cstdio> #include<cstring> using namespace std; int dir[]={1,2,3}; __int64…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4105 题目意思: 给一个字符串,求最大的分隔空格数,记所有被分隔的数为a1,a2,a3,..... 使得 a1<a2>a3<a4>a5..... 解题思路: 简单的dp; 记dp[0][i][j]表示从第i个字符开始到结束,且以第i~j个字符组成的数作为谷值的最大的分隔的数. 记dp[1][i][j]                          ...            …
题意:给你n种花,m个盆,花盆是有顺序的,每种花只能插一个花盘i,下一种花的只能插i<j的花盘,现在给出价值,求最大价值 简单dp #include <iostream> #include<cstdio> #include<cstring> using namespace std; #define N 110 int dp[N][N],a[N][N]; int main(int argc, char** argv) { int n,m,i,j; while(sca…
Problem Description Given a matrix with n rows and m columns ( n+m ,) and you want to go to the number at bottom-right corner (n,m). And you must go right or go down every steps. Let the numbers you go through become an array a1,a2,...,a2k. The cost…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2571 简单dp, dp[n][m] +=(  dp[n-1][m],dp[n][m-1],d[i][k] ) k 为m的因子 PS:0边界要初始为负数(例如-123456789)越大越好 代码: #include <stdio.h> #include <string.h> int dp[25][1005]; #define max(x,y) x > y ? x : y int m…