Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- sys.setrecursionlimit(99999)
- # TCO
- def f0(n):
- return _f0(n, 0, 1)
- def _f0(n, now, next):
- return now if n == 0 else _f0(n - 1, next, (now + next))
- # DP
- def f1(n):
- dp = 11012*[0];
- dp[0] = 0
- dp[1] = 1
- for i in range(2, n+1):
- dp[i] = dp[i-2] + dp[i-1]
- return dp[n]
- # Memoization
- box = [-1 for a in range(20000)]
- def f2(n):
- if box[n] != -1:
- return box[n];
- elif n < 2:
- return n
- else :
- box[n] = f2(n-2) + f2(n-1)
- return box[n]
- print "SECCON{" + str(f0(11011))[:32] + "}"
- print "SECCON{" + str(f1(11011))[:32] + "}"
- print "SECCON{" + str(f2(11011))[:32] + "}"
Add Comment
Please, Sign In to add comment