Created
February 9, 2023 00:21
-
-
Save modos/4d7119398ec3aea3fb836bef7b869a68 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 countWays(n): | |
res = [0] * (n + 4) | |
res[0] = 1 | |
res[1] = 1 | |
res[2] = 2 | |
res[3] = 3 | |
res[4] = 5 | |
res[5] = 8 | |
for i in range(3, n + 1): | |
res[i] = res[i - 1] + res[i - 2] + res[i - 5] | |
return res[n] | |
n = int(input()) | |
print(countWays(n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment