#P1494. [国家集训队] 小 Z 的袜子
[国家集训队] 小 Z 的袜子
Description
Updated on 2020.6.10: time limit updated.
As a somewhat careless person, Xiao Z spends a long time every morning trying to find a pair of socks from a pile of colorful ones. One day, he could no longer stand this annoying process and decided to leave it to fate.
Specifically, Xiao Z numbers his socks from to , then randomly selects two socks to wear from those numbered to . Although Xiao Z does not care whether the two socks form a true pair, he does care about their colors, since wearing two socks of different colors would be embarrassing.
Your task is to tell Xiao Z the probability that he draws two socks of the same color. Of course, Xiao Z wants this probability to be as high as possible, so he may ask multiple queries to help him choose.
However, there are cases with in the testdata. Please handle this case specially and output 0/1.
Input Format
The first line contains two positive integers and . is the number of socks, and is the number of queries Xiao Z asks. The next line contains positive integers , where denotes the color of the -th sock; the same color is represented by the same integer. Then follow lines, each containing two positive integers representing a query.
Output Format
Output lines. For each query, output a fraction on a single line representing the probability that two randomly chosen socks from the interval have the same color. If this probability is , output 0/1. Otherwise, must be in lowest terms (see the sample).
6 4
1 2 3 3 3 2
2 6
1 3
3 5
1 6
2/5
0/1
1/1
4/15
Hint
In of the testdata, .
In of the testdata, .
In of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号