CF1323B.Count Subrectangles

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array aa of length nn and array bb of length mm both consisting of only integers 00 and 11 . Consider a matrix cc of size n×mn \times m formed by following rule: ci,j=aibjc_{i, j} = a_i \cdot b_j (i.e. aia_i multiplied by bjb_j ). It's easy to see that cc consists of only zeroes and ones too.

How many subrectangles of size (area) kk consisting only of ones are there in cc ?

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,y2x_1, x_2, y_1, y_2 ( 1x1x2n1 \le x_1 \le x_2 \le n , 1y1y2m1 \le y_1 \le y_2 \le m ) a subrectangle c[x1x2][y1y2]c[x_1 \dots x_2][y_1 \dots y_2] is an intersection of the rows x1,x1+1,x1+2,,x2x_1, x_1+1, x_1+2, \dots, x_2 and the columns y1,y1+1,y1+2,,y2y_1, y_1+1, y_1+2, \dots, y_2 .

The size (area) of a subrectangle is the total number of cells in it.

输入格式

The first line contains three integers nn , mm and kk ( 1n,m40000,1knm1 \leq n, m \leq 40\,000, 1 \leq k \leq n \cdot m ), length of array aa , length of array bb and required size of subrectangles.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 0ai10 \leq a_i \leq 1 ), elements of aa .

The third line contains mm integers b1,b2,,bmb_1, b_2, \ldots, b_m ( 0bi10 \leq b_i \leq 1 ), elements of bb .

输出格式

Output single integer — the number of subrectangles of cc with size (area) kk 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 cc is:

There are 44 subrectangles of size 22 consisting of only ones in it:

In second example matrix cc is:

首页