Time Limit: 1 second(s) | Memory Limit: 32 MB |
All of you know that GCD means the greatest common divisor. So, you must have thought that this problem requires finding some sort of GCD. Don't worry, you are absolutely right!
Given N positive integers, not necessarily distinct, how many ways you can take 4 integers from the N numbers such that their GCD is 1.
Input
Input starts with an integer T (≤ 20), denoting the number of test cases.
Each case starts with an integer N (4 ≤ N ≤ 10000). The next line contains N integers separated by spaces. The integers will be positive and not greater than 10000.
Output
For each case, print the case number and the number of ways you can take the integers as mentioned above.
Sample Input | Output for Sample Input |
3 4 2 4 6 1 5 1 2 4 6 8 10 12 46 100 131 5 6 7 8 9 10 | Case 1: 1 Case 2: 4 Case 3: 195 |
SPECIAL THANKS: JANE ALAM JAN (SOLUTION, DATASET)
1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include