
一道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 展开
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 展开
1个回答
展开全部
先枚举两行,然后统计一下这两行中对应的例中都是1的个数,然后再用
组合数c(cnt,2)算出这两行中四个角都是1的种数。
总复杂度是n*n*m
组合数c(cnt,2)算出这两行中四个角都是1的种数。
总复杂度是n*n*m

2024-09-01 广告
电学测试台是深圳市华芯测试科技有限公司的核心设备之一,它集成了高精度测量仪器与自动化控制系统,专为半导体芯片、电子元件及模块的电性能检测而设计。该测试台能够迅速、准确地完成电压、电流、电阻、电容及频率等关键参数的测试,确保产品质量符合行业标...
点击进入详情页
本回答由华芯测试提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询