Created
July 23, 2020 08:16
-
-
Save inspirit941/66f04ed08f42f90179bfd86a1da10af9 to your computer and use it in GitHub Desktop.
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
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