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?
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.
For each test case, please output the answer.
3 2 1 2 137 42 99 9 7 1
0.500000 0.029351 0.000000
Info: 本題輸出為浮點數,絕對或相對誤差 1e-6 以下視為正確
Migrated from old NTUJ.
Shik and Tmt
No. | Testdata Range | Score |
---|