CF1323B.Count Subrectangles
普及/提高-
通过率:0%
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.
输入格式
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 .
输出格式
Output single integer — the number of subrectangles of c with size (area) k consisting only of ones.
输入输出样例
输入#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: