Created
July 27, 2021 13:52
-
-
Save igorvanloo/954873e469c5dee1496079ededb30370 to your computer and use it in GitHub Desktop.
Problem 743
This file contains hidden or 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 A(k,n): | |
total = 0 | |
f0 = 1 | |
modulo = 1000000007 | |
power = pow(2, n//k, modulo) | |
for a in range(0, n//k + 1): | |
total = (total + (f0 * pow(power, k-2*a, modulo))) % modulo | |
f0 = (f0*(k-2*a)*(k-2*a-1)) % modulo | |
f0 = (f0*pow((a+1)**2, -1, modulo)) % modulo | |
return total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment