Created
June 22, 2022 05:18
-
-
Save siburu/b4d5ea9201ce8c65dedc483746029336 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prob(a, n, t): | |
rest = t - a | |
if rest < 2: | |
return 0 | |
if rest == 2: | |
return 4 | |
if rest <= n + 1: | |
return rest + 1 | |
if rest <= 2 * n: | |
return 2 * n - rest + 1 | |
return 0 | |
def answer(n, t): | |
sum = 0 | |
for i in range(n): | |
a = i + 1 | |
if a == 1: | |
sum += 2 * prob(a, n, t) | |
else: | |
sum += prob(a, n, t) | |
return sum / (n + 1) / (n + 1) / (n + 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment