Sum=Product
Time limit1sMemory limit1024 MB
Count the contiguous subarrays whose element sum equals their element product, for N up to 300,000 and each A_i up to 300,000.
- Level
Medium6 of 10
- Topics
- Math, Brute force, Two pointers
- Solved
- No attempts yet
Problem
A sequence of length , , is given. Count the integer pairs that satisfy all of the following conditions.
Input
The first line contains the length of the sequence. () The second line contains integers , separated by spaces. ()
Output
Print the number of integer pairs that satisfy the condition.