Skip to content

Instantly share code, notes, and snippets.

@inspirit941
Created July 23, 2020 08:16
Show Gist options
  • Save inspirit941/66f04ed08f42f90179bfd86a1da10af9 to your computer and use it in GitHub Desktop.
Save inspirit941/66f04ed08f42f90179bfd86a1da10af9 to your computer and use it in GitHub Desktop.
import sys
n = int(sys.stdin.readline())
memo = {1:1,2:1,3:1,4:2,5:2}
def find_result(number : int) -> int:
if number in memo:
return memo[number]
memo[number] = find_result(number-1) + find_result(number-5)
return memo[number]
for _ in range(n):
num = int(sys.stdin.readline())
print(find_result(num))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment