Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def exp(p,n):
- if n == 1: return p
- x = exp(p,n//2)**2
- if n % 2 == 1: x *= p
- return x
- N = 10**10
- M = 4000
- ans = 0
- for i in range(N//2):
- flips = (i - 0 + 1) * (N-1 - i + 1) * 2 - 1
- rest = 0.5 * exp(1-2*(flips/(N*N)),M)
- ans += 0.5 + rest
- if rest <= 1e-12:
- ans += 0.5 * ((N//2 - 1) - i) # For j > i, the contribution is almost exactly 0.5
- ans *= 2 # Factor in N//2 <= j <= N-1
- break
- print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement