(动态规划)matrix -- hdu -- 5569
http://acm.hdu.edu.cn/showproblem.php?pid=5569
matrix
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 325 Accepted Submission(s): 196
For each cases, first come 2 integers, n,m(1≤n≤1000,1≤m≤1000)
N+m is an odd number.
Then follows n lines with m numbers ai,j(1≤ai≤100)
写完这题, 我意识到了动态规划最重要的便是状态转移, 虽然以前听别人说, 但是到底没有自己真正体会到的来的贴切
- #include<iostream>
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- #include<algorithm>
- #include<queue>
- using namespace std;
- const int N = ;
- int a[N][N], dp[N][N];
- int main()
- {
- int n, m, i, j;
- while(scanf("%d%d", &n, &m)!=EOF)
- {
- for(i=; i<=n; i++)
- for(j=; j<=m; j++)
- scanf("%d", &a[i][j]);
- memset(dp, 0x3f3f3f3f, sizeof(dp));
- for(i=; i<=n; i++)
- for(j=; j<=m; j++)
- {
- if(i== && j==)
- dp[i][j] = ;
- else if((i+j)&)
- {
- dp[i][j] = min(dp[i-][j]+a[i-][j]*a[i][j], dp[i][j-]+a[i][j-]*a[i][j]);
- }
- else
- dp[i][j] = min(dp[i-][j], dp[i][j-]);
- }
- printf("%d\n", dp[n][m]);
- }
- return ;
- }
(动态规划)matrix -- hdu -- 5569的更多相关文章
- hdu 5569 matrix dp
matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5569 D ...
- hdu 5569 matrix(简单dp)
Problem Description Given a matrix with n rows and m columns ( n+m ,) and you want to go to the numb ...
- HDU 5569 matrix
简单DP /* *********************************************** Author :Zhou Zhentao Email :774388357@qq.com ...
- 【动态规划】HDU 5492 Find a path (2015 ACM/ICPC Asia Regional Hefei Online)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5492 题目大意: 一个N*M的矩阵,一个人从(1,1)走到(N,M),每次只能向下或向右走.求(N+ ...
- 【动态规划】HDU 5781 ATM Mechine
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5781 题目大意: 一个人有[0,K]内随机的钱,每次可以随意取,但是不知道什么时候取完,取钱超过剩余 ...
- 【动态规划】HDU 5791 Two
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5791 题目大意: A,B两个数列,问A的子集和B的子集相等的子集对数.子集内顺序按照数列顺序,相同的 ...
- 【动态规划】HDU 1081 & XMU 1031 To the Max
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1081 http://acm.xmu.edu.cn/JudgeOnline/problem.php?i ...
- 动态规划--模板--hdu 1059 Dividing
Dividing Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total S ...
- 动态规划之HDU水题
做水题的感觉真好系列 HDU 2084 数塔 1: 12: 1 23: 1 2 34: 1 2 3 45: 1 2 3 4 5 dp[i][j]第i行第j个数取得的最大值dp[i][j] = max( ...
随机推荐
- ubuntu 无法挂载U盘
问题描述: usb 1-1: device descriptor read/64,error 18usb 1-1: device descriptor read/64,error 18usb 1-1: ...
- Jmeter分布测试
一.负载机为Linux Linux上安装Jmeter 1.Windows中jmeter整个安装目录copy至Linux /usr/local/autodeploy目录 ps.使用winSCP工具cop ...
- 面向服务的架构(SOA)演变图片
公司项目演变 成熟的公司项目结构 对比 总线-服务的注册与发现
- hdu 5418 (Floyd+哈密顿) 飞向世界
http://acm.hdu.edu.cn/showproblem.php?pid=5418 题目大意是城市的编号是1到n,给出m条路线,表示从a城市飞到b城市飞机要耗多少油,最后问飞机从1出发飞过所 ...
- 转~Jenkins pipeline:pipeline 使用之语法详解
一.引言 Jenkins 2.0的到来,pipline进入了视野,jenkins2.0的核心特性. 也是最适合持续交付的feature. 简单的来说,就是把Jenkins1.0版本中,Project中 ...
- Nowcoder OI赛制测试2 F 假的数学题 - 斯特林公式 + 二分
Description 给定$X$, 找到最小的$N$ 使得$N! > X^X$ 数据范围: $x <= 1e11$ Solution $X^X$ 太大, 高精也存不过, 所以取对数 : ...
- CURLOPT_RETURNTRANSFER
curl_setopt($ch,CURLOPT_RETURNTRANSFER,);//设置返回值不直接输出,例如返回xml格式,会将xml原样输出
- Statement、PreparedStatement、CallableStatement的区别
此三个接口的声明如下: public interface Statement extends Wrapper, AutoCloseable public interface PreparedState ...
- where_1
(二)WHERE //where不单独使用,与match,optional match,start,with搭配 where 与match,optional match 一起用,表示约束 where ...
- IOS 小新兵
2017-07-02 lipo -info BaiduOAuthSDK.a 查看a文件支持的架构 第一个坎: 报错: 未找到模块baiduLogin对应的类BaiduLoginModule.若是自 ...