#ds503. 小Z的袜子
小Z的袜子
Little Z's Socks
Problem Description
As a scatterbrained person, Little Z spends a long time every morning picking out a pair of socks from a pile of colorful ones. Finally one day, unable to bear this annoying sock-finding process any longer, Little Z decides to leave it to fate…
Specifically, Little Z labels the socks from to , and then picks two socks from indices to . Although Little Z does not care whether the two socks form a complete pair, or even whether they are a left and a right sock, he does care about their color — wearing two socks of different colors would be embarrassing.
Your task is to tell Little Z the probability of drawing two socks of the same color. Of course, Little Z wants this probability to be as high as possible, so he may ask several queries to help himself choose.
Input Format
The first line of the input contains two positive integers (). is the number of socks, and is the number of queries Little Z makes.
The next line contains positive integers (), where is the color of the -th sock; the same color is represented by the same number.
The next lines each contain two positive integers (), describing one query.
Output Format
Output lines. For each query, output the fraction on one line, representing the probability of drawing two socks of the same color from the interval . If this probability is , output 0/1; otherwise must be an irreducible fraction.
Sample Input
6 4
1 2 3 3 3 2
2 6
1 3
3 5
1 6
Sample Output
2/5
0/1
1/1
4/15
Sample Explanation
- Query 1: there are possible pairs; drawing two 's has possibility and drawing two 's has possibilities, so the probability is .
- Query 2: there are possible pairs; it is impossible to draw two socks of the same color, so the probability is .
- Query 3: there are possible pairs, all drawing two 's, so the probability is .