Perfect Cube
Practice
3.7 (13 votes)
Basic programming
C++
Problem
15% Success 4676 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code
Given an array \(A\) of \(N\) integers.
Find the count of subarrays whose product of elements is a perfect cube.
Input Format:
- First line contains an integer \(N\).
- Next line contains \(N\) space-separated integers denoting the array elements.
Output Format:
Print the number of subarrays whose product of elements is a perfect cube.
Constraints:
\(1 \le N \le 10^5\)
\(1 \le A[i] \le 10^2\)
Sample Input
4 2 4 6 36
Sample Output
3
Explanation
- Three subarrays with product of elements as a perfect cube are:
- \([2,4] \) product is \(8 (2^3)\)
- \([6,36]\) product is \(216 (6^3)\)
- \([2,4,6,36]\) product is \(1728(12^3)\)
Code Editor
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Submissions
Please login to view your submissions
Similar Problems
Points:20
12 votes
Tags:
ApprovedBasic ProgrammingBrute-force searchEasyOpen
Points:20
26 votes
Tags:
ApprovedBasic ProgrammingEasyOpen
Points:20
9 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementationString Manipulation
Editorial
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor