Prime Array
Practice
3.3 (16 votes)
Basic number theory 1
Algorithms
Number theory
Sieve
Arrays
Math
Problem
77% Success 9155 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

 You are given an array \(A\) having \(N\) integers. Find the number of triplets \((i, j, k)\) such that 

  • \(1 \le i \lt j \lt k \le N\).
  • \(A_i \times A_j \times A_k\) is Prime number.

Input format

  • The first line of input contains an integer \(T\) denoting the number of test cases. The description of each test case is as follows:
  • The first line of each test case contains an integers \(N\).
  • The second line of each test case contains \(N\) integers \(A_1, A_2,\dots, A_N\).

Output format

For each test case, print the number of triplets that satisfies the given conditions in a separate line.

Constraints

\(1\le T \le 10 \\ 3 \leq N \le 10^5\\ 1\le A_i \le 10^5\)

 

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
187 votes
Tags:
ApprovedEasyMathNumber TheoryOpen
Points:20
66 votes
Tags:
AlgorithmsApprovedCombinatoricsEasyMathOpen
Points:20
32 votes
Tags:
ApprovedCombinatoricsEasyImplementationMathOpen