F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

matrix

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1121    Accepted Submission(s): 631


Problem Description
Given a matrix with $n$ rows and $m$ columns ( $n+m$ is an odd number ), at first , you begin with the number at top-left corner (1,1) 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 $a_1, a_2, ... , a_{2k}$. The cost is $a_1*a_2+a_3*a_4+...+a_{2k-1}*a_{2k}$. What is the minimum of the cost?
 

Input
Several test cases(about $5$)

For each cases, first come 2 integers, $n,m(1 \leq n \leq 1000,1 \leq m \leq 1000)$

N+m is an odd number.

Then follows $n$ lines with $m$ numbers $a_i,j ( 1 \leq a_i \leq 100)$
 

Output
For each cases, please output an integer in a line as the answer.
 

Sample Input
2 3 1 2 3 2 2 1 2 3 2 2 1 1 2 4
 

Sample Output
4 8
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 12:25:22, Gzip enabled