Find number of subarrays with ratio of 0 and 1 being x : y

Правка en1, от Neeraj_Kumar_Coder, 2022-08-03 18:18:26

Statement

You are given an array consisting of only 0, 1 and 2. Also given two integers x and y. Your task is to find the number of subarrays with ratio of frequency of 0 and 1 being x : y.

Input

The first line of input contains and integer n, denoting the number of elements in the array.
The next line contains n space separated integers denoting elements of array.
The next line contains two integers x and y.

Output

Output the number of subarrays having 0's and 1's in the ratio x : y.

CONSTRAINTS

2 <= n <= 1e5
1 <= x, y <= n

SAMPLE TEST CASE

5
0 1 2 0 1
1 1

OUTPUT

6
Теги array, subarray, counting, math

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Neeraj_Kumar_Coder 2022-08-03 18:18:26 862 Initial revision (published)