HDU5569/BestCoder Round #63 (div.2) C.matrix DP
matrix
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)
1 2 3
2 2 1
2 3
2 2 1
1 2 4
8
///
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <stack>
using namespace std ;
typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define pb push_back
#define meminf(a) memset(a,127,sizeof(a)); inline ll read()
{
ll x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
//****************************************
#define maxn 100000+50
#define mod 1000000007
#define inf 1000000007 ll a[][],b[maxn],k,dp[][],l[maxn],r[maxn],ans[maxn],D[maxn],n,m;
int main()
{
while(scanf("%d%d",&n,&m)!=EOF)
{
for(int i=;i<=n;i++) {
for(int j=;j<=m;j++) {
scanf("%I64d",&a[i][j]);dp[i][j]=inf;
}
}
dp[][]=;
for(int i=;i<=n;i++) {
for(int j=;j<=n;j++) {
if(i==&&j==) {
dp[i][j+]=min(dp[i][j]+a[i][j]*a[i][j+],dp[i][j+]);
dp[i+][j] =min( dp[i][j]+a[i][j]*a[i+][j],dp[i+][j]);
}
else {
dp[i][j+]=min(dp[i][j]+a[i][j+]*a[i][j+],dp[i][j+]);
dp[i+][j] =min( dp[i][j]+a[i+][j]*a[i+][j],dp[i+][j]);
dp[i+][j+]=min(dp[i][j]+a[i+][j]*a[i+][j+],dp[i+][j+]);
dp[i+][j+] =min( dp[i][j]+a[i][j+]*a[i+][j+],dp[i+][j+]);
}
}
} cout<<dp[n][m]<<endl; } return ;
}
HDU5569/BestCoder Round #63 (div.2) C.matrix DP的更多相关文章
- hdu5569 BestCoder Round #63 (div.2)
题意: 给你一个矩阵,要求从左上角走到右下角,走个的费用:a[1]*a[2] + a[3]*a[4] + ......+ a[2n-1]*a[2n] 思路: 果然不机智,自己把自己套路了 对于每个奇数 ...
- HDU5568/BestCoder Round #63 (div.2) B.sequence2 dp+高精度
sequence2 Problem Description Given an integer array bi with a length of n, please tell me how many ...
- BestCoder Round #63 (div.2)
感觉有些无聊的比赛. A 暴力枚举下就行 B 简单的dp,但是wa了一发后就去先把C做了,然后发现如果输入的100个数,是如1,2,3,4,...,100,然后k=50,个数为c(100,50).果断 ...
- BestCoder Round #81 (div.2) B Matrix
B题...水题,记录当前行是由原矩阵哪行变来的. #include<cstdio> #include<cstring> #include<cstdlib> #inc ...
- HDU5567/BestCoder Round #63 (div.2) A sequence1 水
sequence1 Given an array a with length n, could you tell me how many pairs (i,j) ( i < j ) for a ...
- BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)
Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K ( ...
- BestCoder Round #68 (div.2) tree(hdu 5606)
tree Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submis ...
- BestCoder Round #11 (Div. 2) 题解
HDOJ5054 Alice and Bob Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- hdu5635 BestCoder Round #74 (div.2)
LCP Array Accepts: 131 Submissions: 1352 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 13 ...
随机推荐
- Hi java新特性
java新特性 1995.5.23 java语言 1996 jdk1.0 250个类在API 主要用在桌面型应用程序1997 jdk1.1 500 图形用户界面编程1998 jdk1.2 2300 J ...
- 图片模糊度判断程序(C++、opencv)
//#include<opencv2\opencv.hpp> //using namespace cv; #include <opencv2/core/core.hpp> #i ...
- ios中怎么样自动剪切图片周围超出的部分
UIImageView *image = [[UIImageView alloc] init]; image.clipsToBounds = YES;
- golang与C交互:cgo
1. 在Go中引用C代码很简单, 在 import "C"前用注释引入标准的C代码, 然后使用C.xxx的伪包引用C代码空间的标识符即可. 需要注意, import"C& ...
- 在meteor中使用支付,以及与服务器进行数据交互
how to use Meteor.http.call? Meteor.http is only available on sever side http模块仅能用于server端. 1,add ht ...
- IOS应用程序升级
IOS应用程序升级流程介绍:IOS手机端应用程序需要升级时,打开服务器端html文件(本文为ucab.html文件)->点击在线安装->打开plist文件(本文中为ucab.plist文件 ...
- CentOS 6.3 安装以及配置Apache php mysql
准备篇: 1.配置防火墙,开启80端口.3306端口 vi /etc/sysconfig/iptables -A INPUT -m state –state NEW -m tcp -p tcp –dp ...
- Python实现LR(逻辑回归)
Python实现LR(逻辑回归) 运行环境 Pyhton3 numpy(科学计算包) matplotlib(画图所需,不画图可不必) 计算过程 st=>start: 开始 e=>end o ...
- Android Jni变量对照表
字符 Java类型 C类型 V void void Z jboolean boolean I jint in ...
- FPGA控制HC595
/*****************************************************************************Copyright: 2013File na ...