Skip to content

Instantly share code, notes, and snippets.

@Kernelzero
Created June 15, 2021 07:55
Show Gist options
  • Save Kernelzero/c2233aa5d832b6e2dddc2b9e7a04c935 to your computer and use it in GitHub Desktop.
Save Kernelzero/c2233aa5d832b6e2dddc2b9e7a04c935 to your computer and use it in GitHub Desktop.
import sys
sys.setrecursionlimit(60000)
n = int(input())
count = 0
memo = [0 for _ in range(100001)]
def recursive(step):
if step == 1:
return 1
if step == 2:
return 2
if step == 3:
return 4
if memo[step] != 0 :
return memo[step]%1000
else:
memo[step] = (recursive(step - 3) + recursive(step - 2) + recursive(step - 1))%1000
return memo[step]
print(recursive(n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment