lightoj 1004
很水的一个dp
- #include<cstdio>
- #include<iostream>
- #include<cstring>
- #include<algorithm>
- using namespace std;
- const int N=100;
- int a[2*N+5][N+5],dp[2*N+5][N+5];
- int main()
- {
- int T,n,i,j,ca=0;
- cin>>T;
- while(T--)
- {
- cin>>n;
- memset(a,0,sizeof(a));
- memset(dp,0,sizeof(dp));
- for( i=1;i<=n;i++)
- for(j=1;j<=i;j++)
- cin>>a[i][j];
- for(i=n+1;i<=2*n-1;i++)
- for(j=1;j<=2*n-i;j++)
- cin>>a[i][j];
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=i;j++)
- dp[i][j]=max(dp[i-1][j-1],dp[i-1][j])+a[i][j];
- }
- for(i=n+1;i<=2*n-1;i++)
- {
- for(j=1;j<=2*n-i;j++)
- dp[i][j]=max(dp[i-1][j],dp[i-1][j+1])+a[i][j];
- }
- ca++;
- cout<<"Case "<<ca<<": "<<dp[2*n-1][1]<<endl;
- }
- return 0;
- }
lightoj 1004的更多相关文章
- Monkey Banana Problem LightOJ - 1004
Monkey Banana Problem LightOJ - 1004 错误记录: 1.数组开小2.每组数据数组没有清空 #include<cstdio> #include<cst ...
- lightoj 1004 dp:数字三角形
题目链接:http://lightoj.com/volume_showproblem.php?problem=1004 #include <cstdio> #include <cst ...
- Lightoj 1004 - Monkey Banana Problem
题目链接:http://acm.hust.edu.cn/vjudge/contest/121396#problem/F http://lightoj.com/volume_showproblem.ph ...
- (LightOJ 1004) Monkey Banana Problem 简单dp
You are in the world of mathematics to solve the great "Monkey Banana Problem". It states ...
- lightoj刷题日记
提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...
- 区间DP LightOJ 1422 Halloween Costumes
http://lightoj.com/volume_showproblem.php?problem=1422 做的第一道区间DP的题目,试水. 参考解题报告: http://www.cnblogs.c ...
- bzoj 1004 Cards
1004: [HNOI2008]Cards Description 小春现在很清闲,面对书桌上的N张牌,他决定给每张染色,目前小春只有3种颜色:红色,蓝色,绿色.他询问Sun有 多少种染色方案,Sun ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
- LightOj 1298 - One Theorem, One Year(DP + 欧拉)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1298 题意:给你两个数 n, p,表示一个数是由前 k 个素数组成的,共有 n 个素数 ...
随机推荐
- Yii 关于 find findAll 查找出制定的字段的方法
总所周知 modelName::model() -> find() //找出的是一个对象 modelName::model() -> findALL() //找出的是一个对象集合的数组 如 ...
- linux下面的查找
locate: 速度快 不是实时的,每天定时执行把结果导入数据库 模糊匹配 updatedb --手动生成文件数据库,执行时间较长 find: 实时查找 ...
- SQL技巧之分类汇总
数据表结构username type numaaaa 玉米 1212aaaa 玉米 212bbb 小麦 2323bbb .... 只有两种产品 玉米和小麦,玉米价格1.5,小麦价格 ...
- 通过bat命令批量删除VS查找历史记录
有时候我们会发现我们的VS查找下拉框里面有很多之前的搜索记录,想删除但是却没有地方删除. 网上的方法都是直接找到注册表HKEY_CURRENT_USER\Software\Microsoft\Vis ...
- MongoDB入门三步曲3--部署技术:主备、副本集和数据分片
mongodb部署--主备.副本及数据分片 主备复制 副本集 数据分片 主备复制 主备复制是最基本的一种多点部署方案,在读写分离.热备份.数据恢复等方面具有重要作用. 在真实的生产环境,主备库肯定需要 ...
- PHP初学留神(一)
1.转义字符的使用 这个问题是在php下编写SQL语句的字符串时遇到的,因为在where后面的条件判断经常要用到双引号("")来表示字符.而诸如下面这样的语句就会报错. $quer ...
- err: exp-00056 rra-12154 exp-00000
一直用的是win7系统+oracle11g r1 server端(后简称r1). 由于工作需要装了oracle11g r2 client端(后简称r2). 在装r2之前,r1的导出exp是没有问题的. ...
- linux安装mysql出现Could NOT find Curses (missing CURSES_LIBRARY CURSES_INCLUDE_PATH),提示解决方法
[root@localhost mysql-5.5.11]# cmake . 出现以下错误提示: -- Could NOT find Curses (missing: CURSES_LIBRARY ...
- 8.MVC框架开发(URL路由配置和URL路由传参空值处理)
1.ASP.NET和MVC的路由请求处理 1)ASP.NET的处理 请求---------响应请求(HttpModule)--------处理请求(HttpHandler)--------把请求的资源 ...
- 一步步学习NHibernate(3)——NHibernate增删改查
请注明转载地址:http://www.cnblogs.com/arhat 在上一章中,我们配置了以下NHibernate的运行环境, 并介绍了NHibernate的中两个非常中重要的接口"I ...