一个数列数组的求和再求比率的问题,如何利用C语言的方法编程算法解决

Problem Description
As a cheap labor in a small company, LL has to ride back and forth between school and office every day. It is a tedious trip. So he want to design the most satisfactory riding route. After several day's experiment, he draw the simple map. It contains n*m areas. The school is in (0,0) while the office is in (n-1,m-1). He also record the scenery rank of each area A(i,j) and the time need to ride through each area B(i,j). ( For the start and end, A(0,0), B(0,0), A(n-1,m-1), B(n-1,m-1) are always 0. ) Now, LL defines the satisfactory degree of a round trip as follow:

                                   ∑{ A(i,j) | Area (i,j) is in the riding route (come or go). }

the satisfactory degree = ----------------------------------------------------------------------
∑{ B(i,j) | Area (i,j) is in the riding route (come or go). }

Attention: 1. LL doesn't want to make a detour. So, from school to office he only ride rightward or downward and from office to school only leftward or upward.
2. LL won't pass the same area in the whole round trip except the start and end.

Input
Each test case begins with two integers n,m ( 3<=n,m<=30 ), which is the size of the map. Then n lines follow, each contains m integers A(i,j). Another n lines follow, each contains m integers B(i,j). 1 <= A(i,j),B(i,j) <= 100.

Output
For each case, Output the maximal satisfactory degree he can get in a round trip.

Sample Input
3 3
0 1 2
3 4 5
6 7 0
0 7 6
5 4 3
2 1 0

Sample Output
13/11

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!

相似问题

2
C++语言编程 单调递增最长子序列
1
Python 中数列比较大小的依据是什么?
1
有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13……求出这个数列的前n项之和?
2
求数列的和,用C语言,谢谢
1
这个题我不太懂,好心的大佬们帮我解答一下
1
关于一个数列是否是另一个的子列
1
C语言求数列的的第n项的和
2
新手求助:关于菲波那契数问题怎么写?
1
一个数列递推求解的问题,C语言数据结构怎么解决这个问题呢?
1
给一个整数x将该数插入到序列中,并使新的序列仍然有序,如何C语言
0
计算最小的删除的步数,结果是一个数列怎么计算的?采用C语言
0
等差数列的问题,采用C 语言如何才能进行求解呢??
0
一个用C语言进行偶数求和的复习题,对于每组输入数据,输出一个平均值序列,每组输出占一行。
1
采用C语言解决这个问题,求区间数列的问题怎么实现?
3
1-D数列有序 问题C ACM
0
一个数列的递推的问题,怎么利用C语言和数据结构解决,最大值是K^2
1
用C 语言按照顺序每m个数求出一个平均值,如果最后不足m个,则以实际数量求平均值。
2
求解一个和平方数列求和有关的解法的问题,采用C语言解决这个问题的思路实现怎么做?
1
C语言,输入n个数,找出其中最小的数,将它与最前面的数交换后输出这些数
0
数列递增序列,递减序列,数组实现,计算不同的颜色,使用的C语言谢谢