CF1323B.Count Subrectangles
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a of length n and array b of length m both consisting of only integers 0 and 1. Consider a matrix c of size n×m formed by following rule: ci,j=ai⋅bj (i.e. ai multiplied by bj). It's easy to see that c consists of only zeroes and ones too.
How many subrectangles of size (area) k consisting only of ones are there in c?
A subrectangle is an intersection of a consecutive (subsequent) segment of rows and a consecutive (subsequent) segment of columns. I.e. consider four integers x1,x2,y1,y2 (1≤x1≤x2≤n, 1≤y1≤y2≤m) a subrectangle c[x1…x2][y1…y2] is an intersection of the rows x1,x1+1,x1+2,…,x2 and the columns y1,y1+1,y1+2,…,y2.
The size (area) of a subrectangle is the total number of cells in it.
给你一个长度为 n 的数组 a 和一个长度为 m 的数组 b,其中每个元素均为 0 或 1。考虑一个大小为 n×m 的矩阵 c,其元素按如下规则定义:ci,j=ai⋅bj(即 ai 与 bj 的乘积)。显然,c 中的元素也仅由 0 和 1 构成。
矩阵 c 中有多少个面积(即单元格总数)恰好为 k 且全部由 1 组成的子矩形?
子矩形是指若干连续行与若干连续列的交集。换言之,给定四个整数 x1,x2,y1,y2(满足 1≤x1≤x2≤n,1≤y1≤y2≤m),子矩形 c[x1…x2][y1…y2] 即为行 x1,x1+1,x1+2,…,x2 与列 y1,y1+1,y1+2,…,y2 的交集。
子矩形的大小(面积)即为其所含单元格的总数。
输入格式
The first line contains three integers n, m and k (1≤n,m≤40000,1≤k≤n⋅m), length of array a, length of array b and required size of subrectangles.
The second line contains n integers a1,a2,…,an (0≤ai≤1), elements of a.
The third line contains m integers b1,b2,…,bm (0≤bi≤1), elements of b.
第一行包含三个整数 n、m 和 k(1≤n,m≤40000,1≤k≤n⋅m),分别表示数组 a 的长度、数组 b 的长度以及子矩形所需的大小。
第二行包含 n 个整数 a1,a2,…,an(0≤ai≤1),即数组 a 的元素。
第三行包含 m 个整数 b1,b2,…,bm(0≤bi≤1),即数组 b 的元素。
输出格式
Output single integer — the number of subrectangles of c with size (area) k consisting only of ones.
输出一个整数——即由全为 1 的元素构成、面积为 k 的子矩形 c 的个数。
输入输出样例
输入#1
3 3 2 1 0 1 1 1 1
输出#1
4
输入#2
3 5 4 1 1 1 1 1 1 1 1
输出#2
14
说明/提示
In first example matrix c is:

There are 4 subrectangles of size 2 consisting of only ones in it:

In second example matrix c is:

在第一个例子中,矩阵 c 为:

其中包含 4 个大小为 2、且仅由数字 1 构成的子矩形:

在第二个例子中,矩阵 c 为:

输入解题思路,AI测评打分。不知道怎么写?