Skip to content

Instantly share code, notes, and snippets.

@modos
Created February 9, 2023 00:21
Show Gist options
  • Save modos/4d7119398ec3aea3fb836bef7b869a68 to your computer and use it in GitHub Desktop.
Save modos/4d7119398ec3aea3fb836bef7b869a68 to your computer and use it in GitHub Desktop.
پله نوردی
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