453A.md (1969B)
1 Source: https://codeforces.com/problemset/problem/453/A 2 3 A. Little Pony and Expected Maximum 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game. 22 23 The dice has *m* faces: the first face of the dice contains a dot, the second one contains two dots, and so on, the *m*-th face contains *m* dots. Twilight Sparkle is sure that when the dice is tossed, each face appears with probability . Also she knows that each toss is independent from others. Help her to calculate the expected maximum number of dots she could get after tossing the dice *n* times. 24 25 Input 26 27 A single line contains two integers *m* and *n* (1 ≤ *m*, *n* ≤ 105). 28 29 Output 30 31 Output a single real number corresponding to the expected maximum. The answer will be considered correct if its relative or absolute error doesn't exceed 10 - 4. 32 33 Examples 34 35 Input 36 37 ``` 38 6 1 39 ``` 40 41 Output 42 43 ``` 44 3.500000000000 45 ``` 46 47 Input 48 49 ``` 50 6 3 51 ``` 52 53 Output 54 55 ``` 56 4.958333333333 57 ``` 58 59 Input 60 61 ``` 62 2 2 63 ``` 64 65 Output 66 67 ``` 68 1.750000000000 69 ``` 70 71 Note 72 73 Consider the third test example. If you've made two tosses: 74 75 1. You can get 1 in the first toss, and 2 in the second. Maximum equals to 2. 76 2. You can get 1 in the first toss, and 1 in the second. Maximum equals to 1. 77 3. You can get 2 in the first toss, and 1 in the second. Maximum equals to 2. 78 4. You can get 2 in the first toss, and 2 in the second. Maximum equals to 2. 79 80 The probability of each outcome is 0.25, that is expectation equals to: 81 82  83 84 You can read about expectation using the following link: http://en.wikipedia.org/wiki/Expected_value