Hi-Lo dice game

Problem #403

Tags: simple mathematics games

Who solved this?

No translations... yet

Sandor and Juliska prefer to play games of chance. Note that "S" in both of their names is read as "SH" in English!

Today Juliska proposed modification to basic game with single die:

Juliska argued that out of pure politeness she insists Sandor should play as a banker. And states that anyway there are two equal chances "either I guess right or not, so it is 50%".

Sandor agrees either due to his love for Juliska or due to his lack of love for the mathematical science. We surely know better and easily predict that some time later he loses most of his pocket money. Let's consider single round of the game:

Problem Statement

Supppose that N-sided die is used and K rounds of game are played, every of them with fixed stake of 1 Forint. What is expected amount of Forints to be lost by Sandor to Juliska as a result?

If you would like to know how arbitrary N-sided die may look like, consider that for 2 sides it is just like a coin while 3-sided is like a thin unsharpened pencil, triangular in cross-section and so on.

Input data contain total number of games G in the first line.
Next lines contain two values N and K each.

Answer should for each game contain "mathematical expectation" of the amount Juliska is going to win (and Sandor to lose), separate them with spaces as usual. Precision of 1e-7 should be enough.

Example

input data:
3
2 10
3 5
6 3

answer:
0.0 0.5555556 1.0
You need to login to get test data and submit solution.