HDU_2571_DP
http://acm.hdu.edu.cn/showproblem.php?pid=2571
简单dp,从上到下,从左到右依次更新每一格的最大幸运值。
#include<iostream>
#include<cstdio>
#include<queue>
#define MIN -0x3f3f3f3f
using namespace std; int a[][],maxx[][],n,m; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&m);
for(int i = ;i <= n;i++)
{
for(int j = ;j <= m;j++) scanf("%d",&a[i][j]);
}
for(int i = ;i <= n;i++)
{
for(int j = ;j <= m;j++) maxx[i][j] = MIN;
}
maxx[][] = ;
maxx[][] = ;
for(int i = ;i <= n;i++)
{
for(int j = ;j <= m;j++)
{
maxx[i][j] = max(maxx[i][j-],maxx[i-][j])+a[i][j];
for(int k = j/;k >= ;k--)
{
if(j%k) continue;
maxx[i][j] = max(maxx[i][j],maxx[i][k]+a[i][j]);
}
} }
printf("%d\n",maxx[n][m]);
}
return ; }
HDU_2571_DP的更多相关文章
随机推荐
- 小白学 Python 爬虫(35):爬虫框架 Scrapy 入门基础(三) Selector 选择器
人生苦短,我用 Python 前文传送门: 小白学 Python 爬虫(1):开篇 小白学 Python 爬虫(2):前置准备(一)基本类库的安装 小白学 Python 爬虫(3):前置准备(二)Li ...
- hutool BigExcelWriter 下的autoSizeColumnAll异常问题
autoSizeColumnAll java.lang.IllegalStateException: Could not auto-size column. Make sure the column ...
- tomcat 介绍及环境搭建
一.tomcat介绍 Tomcat 服务器是一个免费的开放源代码的 Web 应用服务器,属于轻量级应用服务器,在中小型 系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试 JSP 程序的首选. ...
- 避免在ASP.NET Core 3.0中为启动类注入服务
本篇是如何升级到ASP.NET Core 3.0系列文章的第二篇. Part 1 - 将.NET Standard 2.0类库转换为.NET Core 3.0类库 Part 2 - IHostingE ...
- python继承简介
继承 是面向对象的三大特性之一 作用: 通过继承可以使一个类获取其它类中的属性和方法 使用方法: 在定义类时,可以在类名后的括号中指定当前类的父类(超类.基类.super) 这样子类(衍生类)就可以直 ...
- Java小白集合源码的学习系列:LinkedList
目录 LinkedList 源码学习 LinkedList继承体系 LinkedList核心源码 Deque相关操作 总结 LinkedList 源码学习 前文传送门:Java小白集合源码的学习系列: ...
- cogs 2632. [HZOI 2016] 数列操作d
2632. [HZOI 2016] 数列操作d ★★★ 输入文件:segment.in 输出文件:segment.out 简单对比时间限制:3 s 内存限制:512 MB [题目描述] ...
- 弹性碰撞 poj 3684
Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Be ...
- Ndarry对象
创建一个 ndarray 只需调用 NumPy 的 array 函数即可: numpy.array(object, dtype = None, copy = True, order = None, s ...
- RTC时间设置
1.命令行输入date,查看系统时间. 2.命令行输入 date -s "2019-01-21 16:03:00" 修改系统时间. 3.命令行输入 hwclock -w 将修改后的 ...