AirbnbOA #1
Subarray Products
估计中等可在线判题
考点(AI 标注)双指针滑窗
Count the non-empty contiguous subarrays whose product of elements does not exceed k; the comparison includes equality.
输入格式
The first line contains n, the second line contains n positive integers, and the third line contains k. 1≤n≤500000, 1≤a[i]≤100, 1≤k≤1000000.
输出格式
Output a single integer answer.
样例 1
输入:
3
2 3 4
6
输出:
4
样例 2
输入:
3
1 2 3
4
输出:
4
样例 3
输入:
3
1 1 1
1
输出:
6
样例说明
The outputs of the three public examples are, in order: 4; 4; 6. Verified by independent enumeration or direct simulation.