[BOJ 11154] Birthday Party

View as PDF

Submit solution

Points: 3
Time limit: 5.0s
Memory limit: 256M

Problem types
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

N persons have been invited to a somewhat special birthday party. Each person brings one present, but the recipent of each present is determined randomly. A person never receives his own present, but all other persons are equally likely recipients. What is the probability that one can find k persons at the party such that person 1 gives his present to person 2, person 2 gives his present to person 3 and so on to person k which gives his present to person 1?

입력 형식

The first line of the input consists of a single integer T, the number of test cases. Each test case consists of two integers N and k.</p>

  • 0 < T ≤ 30
  • 2 ≤ N ≤ 10000000
  • 2 ≤ k ≤ N
## 출력 형식

For each test case, output the probability with an accuracy of at least 10−6.

예제 입력

4
2 2
3 2
3 3
10 3

예제 출력

1.000000000
0.750000000
0.250000000
0.313469843

Comments

There are no comments at the moment.