Cody

# Problem 1159. Coin Tossing: Probability of Same Heads for N tosses

Solution 2156075

Submitted on 10 Mar 2020 by Edward Huang
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass

p = 1 1 ans = 0.5000

2   Pass

p = 1 2 p = 1 2 1 ans = 0.3750

3   Pass

p = 1 3 p = 1 3 3 p = 1 3 3 1 ans = 0.3125

4   Pass

p = 1 4 p = 1 4 6 p = 1 4 6 4 p = 1 4 6 4 1 ans = 0.2734

5   Pass

p = 1 5 p = 1 5 10 p = 1 5 10 10 p = 1 5 10 10 5 p = 1 5 10 10 5 1 ans = 0.2461

6   Pass

p = 1 6 p = 1 6 15 p = 1 6 15 20 p = 1 6 15 20 15 p = 1 6 15 20 15 6 p = 1 6 15 20 15 6 1 ans = 0.2256

7   Pass

p = 1 16 p = 1 16 120 p = 1 16 120 560 p = 1 16 120 560 1820 p = 1 16 120 560 1820 4368 p = 1 16 120 560 1820 4368 8008 p = 1.0e+04 * 0.0001 0.0016 0.0120 0.0560 0.1820 0.4368 0.8008 1.1440 p = 1.0e+04 * 0.0001 0.0016 0.0120 0.0560 0.1820 0.4368 0.8008 1.1440 1.2870 p = 1.0e+04 * 0.0001 0.0016 0.0120 0.0560 0.1820 0.4368 0.8008 1.1440 1.2870 1.1440 p = 1.0e+04 * 0.0001 0.0016 0.0120 0.0560 0.1820 0.4368 0.8008 1.1440 1.2870 1.1440 0.8008 p = 1.0e+04 * 0.0001 0.0016 0.0120 0.0560 0.1820 0.4368 0.8008 1.1440 1.2870 1.1440 0.8008 0.4368 p = 1.0e+04 * 0.0001 0.0016 0.0120 0.0560 0.1820 0.4368 0.8008 1.1440 1.2870 1.1440 0.8008 0.4368 0.1820 p = 1.0e+04 * 0.0001 0.0016 0.0120 0.0560 0.1820 0.4368 0.8008 1.1440 1.2870 1.1440 0.8008 0.4368 0.1820 0.0560 p = 1.0e+04 * 0.0001 0.0016 0.0120 0.0560 0.1820 0.4368 0.8008 1.1440 1.2870 1.1440 0.8008 0.4368 0.1820 0.0560 0.0120 p = 1.0e+04 * 0.0001 0.0016 0.0120 0.0560 0.1820 0.4368 0.8008 1.1440 1.2870 1.1440 0.8008 0.4368 0.1820 0.0560 0.0120 0.0016 p = 1.0e+04 * 0.0001 0.0016 0.0120 0.0560 0.1820 0.4368 0.8008 1.1440 1.2870 1.1440 0.8008 0.4368 0.1820 0.0560 0.0120 0.0016 0.0001 ans = 0.1399

8   Pass

p = 1 20 p = 1 20 190 p = 1 20 190 1140 p = 1 20 190 1140 4845 p = 1 20 190 1140 4845 15504 p = 1 20 190 1140 4845 15504 38760 p = 1 20 190 1140 4845 15504 38760 77520 p = 1 20 190 1140 4845 15504 38760 77520 125970 p = 1.0e+05 * 0.0000 0.0002 0.0019 0.0114 0.0485 0.1550 0.3876 0.7752 1.2597 1.6796 p = 1.0e+05 * 0.0000 0.0002 0.0019 0.0114 0.0485 0.1550 0.3876 0.7752 1.2597 1.6796 1.8476 p = 1.0e+05 * 0.0000 0.0002 0.0019 0.0114 0.0485 0.1550 0.3876 0.7752 1.2597 1.6796 1.8476 1.6796 p = 1.0e+05 * 0.0000 0.0002 0.0019 0.0114 0.0485 0.1550 0.3876 0.7752 1.2597 1.6796 1.8476 1.6796 1.2597 p = 1.0e+05 * 0.0000 0.0002 0.0019 0.0114 0.0485 0.1550 0.3876 0.7752 1.2597 1.6796 1.8476 1.6796 1.2597 0.7752 p = 1.0e+05 * 0.0000 0.0002 0.0019 0.0114 0.0485 0.1550 0.3876 0.7752 1.2597 1.6796 1.8476 1.6796 1.2597 0.7752 0.3876 p = 1.0e+05 * 0.0000 0.0002 0.0019 0.0114 0.0485 0.1550 0.3876 0.7752 1.2597 1.6796 1.8476 1.6796 1.2597 0.7752 0.3876 0.1550 p = 1.0e+05 * 0.0000 0.0002 0.0019 0.0114 0.0485 0.1550 0.3876 0.7752 1.2597 1.6796 1.8476 1.6796 1.2597 0.7752 0.3876 0.1550 0.0484 p = 1.0e+05 * 0.0000 0.0002 0.0019 0.0114 0.0485 0.1550 0.3876 0.7752 1.2597 1.6796 1.8476 1.6796 1.2597 0.7752 0.3876 0.1550 0.0484 0.0114 p = 1.0e+05 * Columns 1 through 18 0.0000 0.0002 0.0019 0.0114 0.0485 0.1550 0.3876 0.7752 1.2597 1.6796 1.8476 1.6796 1.2597 0.7752 0.3876 0.1550 0.0484 0.0114 Column 19 0.0019 p = 1.0e+05 * Columns 1 through 18 0.0000 0.0002 0.0019 0.0114 0.0485 0.1550 0.3876 0.7752 1.2597 1.6796 1.8476 1.6796 1.2597 0.7752 0.3876 0.1550 0.0484 0.0114 Columns 19 through 20 0.0019 0.0002 p = 1.0e+05 * Columns 1 through 18 0.0000 0.0002 0.0019 0.0114 0.0485 0.1550 0.3876 0.7752 1.2597 1.6796 1.8476 1.6796 1.2597 0.7752 0.3876 0.1550 0.0484 0.0114 Columns 19 through 21 0.0019 0.0002 0.0000 ans = 0.1254

9   Pass

p = 1 24 p = 1 24 276 p = 1 24 276 2024 p = 1 24 276 2024 10626 p = 1 24 276 2024 10626 42504 p = 1 24 276 2024 10626 42504 134596 p = 1.0e+05 * 0.0000 0.0002 0.0028 0.0202 0.1063 0.4250 1.3460 3.4610 p = 1.0e+05 * 0.0000 0.0002 0.0028 0.0202 0.1063 0.4250 1.3460 3.4610 7.3547 p = 1.0e+06 * 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 p = 1.0e+06 * 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 p = 1.0e+06 * 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 2.4961 p = 1.0e+06 * 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 2.4961 2.7042 p = 1.0e+06 * 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 2.4961 2.7042 2.4961 p = 1.0e+06 * 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 2.4961 2.7042 2.4961 1.9613 p = 1.0e+06 * 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 2.4961 2.7042 2.4961 1.9613 1.3075 p = 1.0e+06 * 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 2.4961 2.7042 2.4961 1.9613 1.3075 0.7355 p = 1.0e+06 * 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 2.4961 2.7042 2.4961 1.9613 1.3075 0.7355 0.3461 p = 1.0e+06 * Columns 1 through 18 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 2.4961 2.7042 2.4961 1.9613 1.3075 0.7355 0.3461 Column 19 0.1346 p = 1.0e+06 * Columns 1 through 18 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 2.4961 2.7042 2.4961 1.9613 1.3075 0.7355 0.3461 Columns 19 through 20 0.1346 0.0425 p = 1.0e+06 * Columns 1 through 18 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 2.4961 2.7042 2.4961 1.9613 1.3075 0.7355 0.3461 Columns 19 through 21 0.1346 0.0425 0.0106 p = 1.0e+06 * Columns 1 through 18 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 2.4961 2.7042 2.4961 1.9613 1.3075 0.7355 0.3461 Columns 19 through 22 0.1346 0.0425 0.0106 0.0020 p = 1.0e+06 * Columns 1 through 18 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 2.4961 2.7042 2.4961 1.9613 1.3075 0.7355 0.3461 Columns 19 through 23 0.1346 0.0425 0.0106 0.0020 0.0003 p = 1.0e+06 * Columns 1 through 18 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 2.4961 2.7042 2.4961 1.9613 1.3075 0.7355 0.3461 Columns 19 through 24 0.1346 0.0425 0.0106 0.0020 0.0003 0.0000 p = 1.0e+06 * Columns 1 through 18 0.0000 0.0000 0.0003 0.0020 0.0106 0.0425 0.1346 0.3461 0.7355 1.3075 1.9613 2.4961 2.7042 2.4961 1.9613 1.3075 0.7355 0.3461 Columns 19 through 25 0.1346 0.0425 0.0106 0.0020 0.0003 0.0000 0.0000 ans = 0.1146

10   Pass
assert(~isequal(1,2))

11   Pass

p = 1 32 p = 1 32 496 p = 1 32 496 4960 p = 1 32 496 4960 35960 p = 1 32 496 4960 35960 201376 p = 1 32 496 4960 35960 201376 906192 p = 1 32 496 4960 35960 201376 906192 3365856 p = 1 32 496 4960 35960 201376 906192 3365856 10518300 p = 1 32 496 4960 35960 201376 906192 3365856 10518300 28048800 p = 1.0e+07 * 0.0000 0.0000 0.0000 0.0005 0.0036 0.0201 0.0906 0.3366 1.0518 2.8049 6.4512 p = 1.0e+08 * 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 p = 1.0e+08 * 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 p = 1.0e+08 * 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 p = 1.0e+08 * 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 p = 1.0e+08 * 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 p = 1.0e+08 * 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 p = 1.0e+08 * 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Column 19 4.7144 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Columns 19 through 20 4.7144 3.4737 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Columns 19 through 21 4.7144 3.4737 2.2579 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Columns 19 through 22 4.7144 3.4737 2.2579 1.2902 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Columns 19 through 23 4.7144 3.4737 2.2579 1.2902 0.6451 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Columns 19 through 24 4.7144 3.4737 2.2579 1.2902 0.6451 0.2805 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Columns 19 through 25 4.7144 3.4737 2.2579 1.2902 0.6451 0.2805 0.1052 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Columns 19 through 26 4.7144 3.4737 2.2579 1.2902 0.6451 0.2805 0.1052 0.0337 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Columns 19 through 27 4.7144 3.4737 2.2579 1.2902 0.6451 0.2805 0.1052 0.0337 0.0091 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Columns 19 through 28 4.7144 3.4737 2.2579 1.2902 0.6451 0.2805 0.1052 0.0337 0.0091 0.0020 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Columns 19 through 29 4.7144 3.4737 2.2579 1.2902 0.6451 0.2805 0.1052 0.0337 0.0091 0.0020 0.0004 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Columns 19 through 30 4.7144 3.4737 2.2579 1.2902 0.6451 0.2805 0.1052 0.0337 0.0091 0.0020 0.0004 0.0000 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Columns 19 through 31 4.7144 3.4737 2.2579 1.2902 0.6451 0.2805 0.1052 0.0337 0.0091 0.0020 0.0004 0.0000 0.0000 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Columns 19 through 32 4.7144 3.4737 2.2579 1.2902 0.6451 0.2805 0.1052 0.0337 0.0091 0.0020 0.0004 0.0000 0.0000 0.0000 p = 1.0e+08 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0004 0.0020 0.0091 0.0337 0.1052 0.2805 0.6451 1.2902 2.2579 3.4737 4.7144 5.6572 6.0108 5.6572 Columns 19 through 33 4.7144 3.4737 2.2579 1.2902 0.6451 0.2805 0.1052 0.0337 0.0091 0.0020 0.0004 0.0000 0.0000 0.0000 0.0000 ans = 0.0993

12   Pass