LCMAX

3

3 votes
Data Structures, Segment Trees, Advanced Data Structures
Problem

You are given an array a of integers. But there is something special about these integers. All of the integers are square free. Formally, for each i, if  ai=pq11pq22...pq2m  where every pj(1jm) is a prime, then qj1.
Coming to the problem, You need to find the number of subarrays where the maximum number of the subarray is also the LCM (Least Common Multiple) of the subarray.

 

Input Format

  • The first line contains a single integer T the number of test cases.
  • The first line of each test case contains a single integer nthe size of the array.
  • The next line contains n square free integers.

Output Format

  • For each test, output the number of subarrays that fullfil the condition.

Constraints

  • 1T100
  • 1n105
  • 1ai105 for each i from 1 to n.
  • The sum of n over all test cases does not exceed 105.
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

In the second test case, the subarrays that satisfy the conditon are:

[1,1],[1,2],[2,2],[3,3],[4,4].

Editor Image

?