F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

I love triples

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 581    Accepted Submission(s): 135


Problem Description
Now Mr.I has an array $a$ consisting of $n$ integers.

He now wants to know how many triples $(i, j, k)$ satisfy $i<j<k$ and $a_i * a_j * a_k$ is a square number .

The definition of a square number is a number that can be expressed as the product of two identical integers.

For example, 1, 4, 9, 16, 25, and 36 are square numbers, but 2, 3, and 6 are not.
 

Input
The first line contains an integer $T(T\leq 6)$ . Then $T$ test cases follow.

Each test case contains two lines.

The first one contains an integer $n(1\leq n\leq {10}^5)$ — length of the array $a$.

The second one contains $n$ integers $a_1,a_2,...,a_n(1\leq a_i\leq {10}^5)$
 

Output
For each test case, output a single line containing a single integer — the number of triples that meet the conditions.
 

Sample Input
1 6 1 2 4 8 16 32
 

Sample Output
10
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-12 05:48:16, Gzip enabled