Perfect Cube

3.7

13 votes
, Basic Programming, C++
Problem

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:

1N1051A[i]102

 

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation
  • Three subarrays with product of elements as a perfect cube are:
    • [2,4] product is 8(23)
    • [6,36] product is 216(63)
    • [2,4,6,36] product is 1728(123)
Editor Image

?