Xenny and K-Equal-Triplets
Practice
3.5 (487 votes)
Hiring
Open
Approved
Easy
Mathematics
Problem
38% Success 7821 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Xenny had N numbers and he loved equal triplets (An equal triplet is group of 3 numbers that are equal).
He defined a K-equal-triplet as a triplet in which all 3 integers were equal to K.
Given an integer K, he wanted to find out the probability of getting a K-equal triplet, from the N numbers.

Xenny is bad at understanding floating point numbers. Help him to find the probability in terms of a fraction, reduced to its lowest terms.

Input

First line contains a single integer - T, the total number of testcases.
T testcases follow.
Each testcase consists of 2 lines:
First line contains 2 space-separated integers - N and K, which represent the total number of integers Xenny had, and the value K whose K-equal-triplet was required.

Output

For each testcase, print the probability of finding a K-equal-triplet in terms of the lowest fraction.
For example, if the answer is 4/8, you must print 1/2, which is the lowest reduced fraction of 4/8.

Constraints

1 ≤ T ≤ 50
1 ≤ N ≤ 106
1 ≤ Numbers ≤ 109
1 ≤ K ≤ 109

Note:

1) 2 testcase files are large (about 20 MB) in size. Please use fast I/O in your code.
2) Candidates need to attempt only one of the given problems

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:30
290 votes
Tags:
ReadyBit manipulationApprovedEasy-Medium
Points:20
512 votes
Tags:
OpenApprovedEasy
Points:20
594 votes
Tags:
Greatest common divisorHiringEasyMathematicsOpenApproved