Submit | All submissions | Best solutions | Back to list |
FAVDICE - Favorite Dice |
BuggyD loves to carry his favorite die around. Perhaps you wonder why it's his favorite? Well, his die is magical and can be transformed into an N-sided unbiased die with the push of a button. Now BuggyD wants to learn more about his die, so he raises a question:
What is the expected number of throws of his die while it has N sides so that each number is rolled at least once?
Input
The first line of the input contains an integer t, the number of test cases. t test cases follow.
Each test case consists of a single line containing a single integer N (1 <= N <= 1000) - the number of sides on BuggyD's die.
Output
For each test case, print one line containing the expected number of times BuggyD needs to throw his N-sided die so that each number appears at least once. The expected number must be accurate to 2 decimal digits.
Example
Input: 2 1 12 Output: 1.00 37.24
Added by: | Matthew Reeder |
Date: | 2006-10-29 |
Time limit: | 1s |
Source limit: | 30000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ERL JS-RHINO NODEJS PERL6 VB.NET |
Resource: | Al-Khawarizm 2006 |
hide comments
|
||||||||
2013-01-28 22:07:42 saket diwakar
all thanks to wiki...:) |
||||||||
2012-11-15 17:26:16 Anirban
using float gives WA,why?? |
||||||||
2012-09-06 17:13:19 ppo
@sarih i have checked for the case you have given but it still giving WA |
||||||||
2012-03-18 06:58:00 alphaplus
good tutorial on expectation value given on codechef.com |
||||||||
2011-02-20 20:22:36 Alex Anderson
@hari It is asking for the expected value - it is a defined concept which can be a decimal. Check wikipedia. |
||||||||
2011-01-29 06:44:12 N Hari Prasad
how can the "number of times he throws" be a decimal?? |