#P3330. [ZJOI2011] 看电影

[ZJOI2011] 看电影

Description

During a rare holiday, Xiaobai’s (Xiaobai) class organizes a movie trip. However, because many people watch movies during holidays, it is hard to seat everyone in the same showing. Finally, they find a cinema in a remote alley, but its seating assignment is special, as follows:

The cinema has KK seats, labeled 1K1 \sim K. After buying a ticket, each person is randomly assigned a seat. Specifically, an integer is chosen uniformly at random from 1K1 \sim K, and let it be LL.

If seat LL is empty, this seat is assigned to the person. Otherwise, increase LL by one and repeat the previous step; if there is no seat numbered LL, then the person has to stand to watch the movie, i.e., a standing ticket.

There are NN people in Xiaobai’s class (including Xiaobai). As a math enthusiast, Xiaobai wants to know the probability that the whole class can get seats.

Input Format

Multiple test cases. The first line contains an integer TT denoting the number of test cases. Then each of the next TT lines contains two integers N,KN,K denoting the number of people and the number of seats in the cinema.

Output Format

For each test case, output two integers A,BA,B on one line, indicating that the answer is AB\frac{A}{B}. You need to ensure gcd(A,B)=1\gcd(A,B) = 1.

3
1 1
2 1
2 2
1 1
0 1
3 4

Hint

For 100%100 \% of the testdata, 1T501 \leq T \leq 50, 1N,K2001 \leq N,K \leq 200.

Translated by ChatGPT 5