早教吧 育儿知识 作业答案 考试题库 百科 知识分享

一道acm水编程题,ProblemB:CounttherectanglesTimeLimit:1SecMemoryLimit:128MBSubmit:24Solved:7[Submit][Status][WebBoard]DescriptionYouaregivennumbersofrectanglesmadeof'1'sand'0's.Calculatehowmanysmallrectangleswhichhavef

题目详情
一道acm水编程题,
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
▼优质解答
答案和解析
先枚举两行,然后统计一下这两行中对应的例中都是1的个数,然后再用
组合数c(cnt,2)算出这两行中四个角都是1的种数.
总复杂度是n*n*m