#C5712. Number of Subarrays With Product Less Than Target

    ID: 49392 Type: Default 1000ms 256MiB

Number of Subarrays With Product Less Than Target

Number of Subarrays With Product Less Than Target

Given an array of positive integers (nums) and a positive integer (target), your task is to count the number of contiguous (non-empty) subarrays such that the product of all the elements in the subarray is strictly less than (target).

For a subarray spanning indices (l) to (r), the product is defined as (\prod_{i=l}^{r} nums[i]).

You need to implement a solution that, given the array and (target), returns the total count of such subarrays.

inputFormat

The input is read from standard input (stdin).

The first line contains two integers (n) and (target), where (n) indicates the number of elements in the array.
The second line contains (n) space-separated positive integers representing the array (nums).

outputFormat

Output a single integer to standard output (stdout), denoting the number of contiguous subarrays where the product of the elements is less than (target).## sample

4 100
10 5 2 6
8