DCEPC12H - Height of Expectation

Welcome To ICPC! ICPC is a programming competition in which N teams participate every year. Out of N teams, K number of teams has been selected from our college. You know what? K is always a prime number. Coincidence! Before going to ICPC, we want to calculate our expected overall score of our college.

Expected Overall score is defined as expected median value of our college team’s ranks.

All the ranks are distinct. Team’s rank value always lies between 1 to N.

Input

First line consists of T, the number of test cases.

Each of the next T lines contains 2 space separated integers N and K.

Output

Output T lines each line containing expected overall score of our college. You should output at least 6 digits after decimal.

Constraints

1<=T<=500

1<=N<=100

1<=K<=10

N>=K

Example

Input:
1
3 3

Output:
2.0000000

Added by:dce coders
Date:2013-12-07
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C CSHARP C++ 4.3.2 CPP C99 HASK JAVA PAS-GPC PAS-FPC PYTHON PYTHON3 PY_NBC

hide comments
2018-07-11 19:47:19
wikipedia- "expected median value".


Last edit: 2018-07-11 19:48:32
2017-08-20 18:26:16
what a waste!
2017-07-11 12:02:57
don't think too much(it costed me 1 wa )
hint: no need of k
2017-02-08 06:19:41
Easy one :-)
2016-06-24 15:30:00
Just google "Expected Median Value" and compare it with the mean.
2016-06-09 13:40:32
" Expected Median Value" someone please explain?
2016-06-01 13:48:53
read up "average median value" and write the code :P
2016-04-15 17:04:56 vipul_vipul
Maths ROXXXX..
2015-07-17 11:14:02 Avi Aryan
Easy pattern
2015-06-17 14:45:52 Mayank Agarwal
what do we mean by Expected Median Value??
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.