TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Long time ago, in the middle ages of Triangle Kingdom, there was a gracious king. The king granted all of the children in the kingdom a chance to learn how to write a program. That’s why the offspring called him the “King For Children” (KFC in short). Such a great king not only allowed children to write a program, but also trained them into the most brilliant soldiers best ever had. The king aligned and numbered them from 1 to n, gave each soldier a vuvuzela (instead of rifle for safety), then asked the soldiers pass his vuvuzela to someone. The king called this process “permute”. After “permute”, all soldier must have exactly one vuvuzela in hand. Then, the king asked them “permute” again in the same pattern: everyone passed his vuvuzela in hand into the same person he or she first sent to. Moreover, if one got his/her own vuvuzela back in hand, he/she would sit down and take a rest. The king wished that this activity will be ended within at most k “permute”s. In addition, the king dislike the number M (maybe M for Old MacDonates’, he had a farm, of course, which grows junk foods.) The king did not want any of the soldiers start taking a rest on every M-th “permute”. Now, the soldiers performed a “permute” in a random manner, each outcome with same probability. Could you help the king to calculate the probability if the “permute” would make the king happy?

Input Format

First line contains an integer T(1<=T<=100) indicating the number of test cases.
For each test case, there are three integers n, k, M (1<=n, k, M<=106) in a line.

Output Format

For each test case, please output the answer.

Sample Input 1

3
2 1 2
137 42 99
9 7 1

Sample Output 1

0.500000
0.029351
0.000000

Hints

Info: 本題輸出為浮點數,絕對或相對誤差 1e-6 以下視為正確

Problem Source

Migrated from old NTUJ.

Shik and Tmt

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 2000 65536 200