一道acm水编程题,高分求解答,解答后加加悬赏分

ProblemB:CounttherectanglesTimeLimit:1SecMemoryLimit:128MBSubmit:24Solved:7[Submit][S... Problem B: Count the rectangles
Time Limit:1 Sec Memory Limit:128 MB
Submit:24 Solved:7
[Submit][Status][Web Board]
Description
You are given numbers of rectangles made of '1's and '0's.Calculate how many small rectangles which have four '1's on the four corners.

Input

There are several test cases, each test case starts with a line containing two positive integers n and m. n and m is the size of the rectangle (1<=n<=100, 1<=m<=100). Next follow a rectangle which contains only number '0' and '1'. The input will finish with the end of file.

Output
The number of rectangles which meet the requirements.

Sample Input
3 4
1 0 1 0
0 1 1 0
1 1 1 0

Sample Output
2

说一下思路就行了
就是输入一个矩阵 求出这个矩阵包含多少个小矩阵 小矩阵的四周都为1
展开
 我来答
百度网友28b4182
2013-05-10 · TA获得超过7222个赞
知道大有可为答主
回答量:4847
采纳率:100%
帮助的人:1855万
展开全部
先枚举两行,然后统计一下这两行中对应的例中都是1的个数,然后再用

组合数c(cnt,2)算出这两行中四个角都是1的种数。
总复杂度是n*n*m
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式