Skip to content

Instantly share code, notes, and snippets.

@maehrm
Last active January 17, 2026 09:15
Show Gist options
  • Select an option

  • Save maehrm/9c4980788c6df4986a6eb056ac81101f to your computer and use it in GitHub Desktop.

Select an option

Save maehrm/9c4980788c6df4986a6eb056ac81101f to your computer and use it in GitHub Desktop.
D - Yet Another Recursive Function https://atcoder.jp/contests/abc275/tasks/abc275_d
import sys
sys.setrecursionlimit(10**7)
def f(k, memo):
if k in memo:
return memo[k]
else:
memo[k] = f(k // 2, memo) + f(k // 3, memo)
return memo[k]
N = int(input())
print(f(N, {0: 1}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment