Problem:


観音堂

一郎君の家の裏山には観音堂があります。この観音堂まではふもとから 30 段の階段があり、一郎君は、毎日のように観音堂まで遊びに行きます。一郎君は階段を１足で３段まで上がることができます。遊んでいるうちに階段の上り方の種類（段の飛ばし方の個数）が非常にたくさんあることに気がつきました。

そこで、一日に 10 種類の上り方をし、すべての上り方を試そうと考えました。しかし数学を熟知しているあなたはそんなことでは一郎君の寿命が尽きてしまうことを知っているはずです。

一郎君の計画が実現不可能であることを一郎君に納得させるために、階段の段数 n を入力とし、一日に 10 種類の上り方をするとして、一郎君がすべての上り方を実行するのに要する年数を出力するプログラムを作成してください。一年は 365 日として計算してください。一日でも必要なら一年とします。365 日なら 1 年であり、366 日なら 2 年となります。

Input

複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。
各データセットとして、段数を表す１つの整数 n (1 ≤ n ≤ 30) が１行に与えられます。

データセットの数は 30 を超えません。

Output

データセットごとに一郎君がすべての上り方を実行するのに必要な年数（整数）を１行に出力します。

Sample Input

1
10
20
25
0

Output for the Sample Input

1
1
34
701



Sample input:
1
10
20
25
0


Sample output:
1
1
34
701

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    else:
        if n==1:
            print(1)
        elif n==2:
            print(1)
        else:
            A=[0]*(n+1)
            A[0]=1
            A[1]=1
            A[2]=2
            for i in range(3,n+1):
                A[i]=A[i-1]+A[i-2]+A[i-3]
            print(A[n]//3650+1)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    else:
        A=[0]*(n+10)
        A[0]=1
        A[1]=1
        A[2]=2
        if n==1:
            print(1)
        elif n==2:
            print(1)
        else:
            for i in range(3,(n+1)):
                A[i]=A[i-1]+A[i-2]+A[i-3]
            print((A[n]//3650)+1)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break 
    else:
        A=[0]*(n+48)
        A[0]=1
        A[1]=1
        A[2]=2
        if n==1:
            print(1)
        elif n==2:
            print(1)
        else:
            for i in range (3,(n+1)):
                A[i]=A[i-1]+A[i-2]+A[i-3]
            print((A[n])//3650+1)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    else:
        A=[0]*(n+10)
        A[0]=1
        A[1]=1
        A[2]=2
        if n==1:
            print(1)
        elif n==2:
            print(1)
        else:
            for i in range(3,(n+1)):
                A[i]=A[i-1]+A[i-2]+A[i-3]
            print((A[n])//3650+1)

Submission status: Accepted

Solution code:
while True:
   n=int(input())
   if n==0:
      break
   else:
      if n==1:
           print(1)
      elif n==2:
           print(1)
      else:
        A=[0]*(n+1) #地面が１なのでｎ段目までは要素がｎ+1
        A[0]=1
        A[1]=1
        A[2]=2
        for i in range(3,(n+1)): #1が3からnまで変化する
          A[i]=A[i-1]+A[i-2]+A[i-3]
        print((A[n])//3650+1)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0 : 
        break
    else :
        A = [0]*(n+10)
        A[0] = 1
        A[1] = 1
        A[2] = 2
        for i in range (3,n+1):
            A[i] = A[i-1] + A[i-2] + A[i-3]
        print(A[n]//3650 + 1)

Submission status: Accepted

Solution code:
while True:
  n=int(input())
  if n==0:
    break
  elif n==1 or n==2:
    print(1)
  else:
    A=[0]*(n+1)
    A[0]=1
    A[1]=1
    A[2]=2
    for i in range(3,n+1):
      A[i]=A[i-1]+A[i-2]+A[i-3]
    print(A[n]//3650+1)

Submission status: Accepted

Solution code:
while True:
    n =int(input())
    if n==0:
        break
    A=[0]*32
    A[0]=0
    A[1]=1
    A[2]=2
    A[3]=4
    for i in range(4,31):
        A[i]=A[i-1]+A[i-2]+A[i-3]
    a=A[n]//3650+1
    print(a)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    else:
        A=[0]*31
        A[0]=1
        A[1]=1
        A[2]=2
        for i in range(3,n+1):
            A[i]=A[i-1]+A[i-2]+A[i-3]
    print(A[n]//3650+1)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    else:
#A(0)=1 A(1)=1 A(2)=2 An=A(n-1)+A(n-2)+A(n-3)
        A=[0]*40
        A[0]=1
        A[1]=1
        A[2]=2
        for i in range (3,31):
            A[i]=A[i-1]+A[i-2]+A[i-3]
        if A[n]%3650==0:
            print(A[n]//3650)
        else:
            print((A[n]//3650)+1)

Submission status: Accepted

Solution code:
import math

while True:
    n=int(input())
    if n == 0:
        break
    elif n == 1:
        A=[1]*1
        
    elif n == 2:
        A=[0]*2
        A[0]=1
        A[1]=2
    elif n ==3:
        A=[0]*3
        A[0]=1
        A[1]=2
        A[2]=4
        
    else:
        A=[0]*n
        A[0]=1
        A[1]=2
        A[2]=4
    
        for t in range(3,n):
            A[t]=A[t-1]+A[t-2]+A[t-3]
        
        
    print(math.ceil(A[n-1]/3650))

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    else:
        x=[0]*31
        x[0]=1
        x[1]=1
        x[2]=2
        for i in range(3,n+1):
            x[i]=x[i-3]+x[i-2]+x[i-1]
    print((x[n]//3650)+1)

Submission status: Accepted

Solution code:
#演習2－5　
while True:
    n=int(input())
    if n==0:
        break
    else:
        A=[0]*40
        A[0]=1
        A[1]=1
        A[2]=2
        for i in range(3,31):
            A[i]=A[i-1]+A[i-2]+A[i-3]
    print((A[n]//3650)+1)

Submission status: Accepted

Solution code:
dp = [0] * 31
dp[0] = 1
dp[1] = 1
dp[2] = 2

for i in range(3, 31):
    dp[i] = dp[i-1]+dp[i-2]+dp[i-3]

while(1):
    n = int(input())
    if not n:
        break
    print((dp[n]-1)//3650+1)

Submission status: Accepted

Solution code:
dp=[0]*31
dp[0]=1
for i in range(0,30):
    if i<30 :
        dp[i+1]+=dp[i]
    if i<29 :
        dp[i+2]+=dp[i]
    if i<28 :
        dp[i+3]+=dp[i]
while True:
    n=int(input())
    if n==0:
        break
    print((dp[n]//3650)+1)

Submission status: Accepted

Solution code:
import math

while True:
    N = int(input())
    if N == 0:
        break

    dp = (N+1)*[0]
    dp[0]=1

    for i in range(1,N+1):
        for j in range(1,min(4,i+1)):
            dp[i] += dp[i-j]

    print(math.ceil(dp[N]/3650))

Submission status: Accepted

Solution code:
from math import ceil
# トリボナッチ数列
dp = [1, 1, 2]
for i in range(3, 31):
    dp.append(dp[i-1] + dp[i-2] + dp[i-3])

while True:
    a = int(input())
    if a == 0:
        break
    print(ceil(dp[a]/10/365))

Submission status: Accepted

Solution code:
def kannondou(x):
    dp = [0]*(x+1)
    dp[0] = 1
    for i in range(1, x+1):
        for j in range(1, 4):
            if 0 <= i - j:
                dp[i] += dp[i-j]
    return dp[-1]//3650 + 1

while True:
    a = int(input())
    if a == 0:
        break
    print(kannondou(a))

Submission status: Accepted

Solution code:
A = [0 for _ in range(32)]
A[0] = 1
for i in range(1, 32):
    A[i] = A[i-1]
    if i > 1:
        A[i] += A[i-2]
        if i > 2:
            A[i] += A[i-3]

while True:
    n = int(input())
    if n ==0:
        break
    else:
        print(A[n]//3650 + 1)

Submission status: Accepted

Solution code:
while True:
    n= int(input())
    if n==0:
        break

    a=[1,1,2,4]
    for i in range(4,n+1):
        a.append(a[i-1]+a[i-2]+a[i-3])
    if a[n] % 3650 ==0:
        print(a[n]/3650)
    else:
        print(a[n]//3650 +1 )

Submission status: Accepted

Solution code:
import itertools,math,sys
def I(): return int(sys.stdin.readline().rstrip())
dp = [0]*31
dp[0],dp[1],dp[2] = 1,1,2
for i,j in itertools.product(range(3,31),[1,2,3]):
    dp[i] += dp[i-j]
while 1:
    n = I()
    if n==0:
        break
    print(math.ceil(dp[n]/10/365))

Submission status: Accepted

Solution code:
import math

N=[]
for _ in range(30):
  n=int(input())
  if n==0: break
  N.append(n)

for n in N:
  dp=[0]*31
  dp[0]=1
  dp[1]=1
  dp[2]=2
  for i in range(3,n+1):
    dp[i]=dp[i-1]+dp[i-2]+dp[i-3]
  print(math.ceil(dp[n]/10/365))

Submission status: Accepted

Solution code:
import math


while True:
    n = int(input())
    if n == 0:
        break
    dp = [0] * (n + 1)
    dp[0] = 1
    for i in range(n):
        dp[i+1] += dp[i]
        if i > 0:
            dp[i+1] += dp[i-1]
        if i > 1:
            dp[i+1] += dp[i-2]
    print(math.ceil((dp[-1] / 10) / 365))

Submission status: Accepted

Solution code:
import math
a = []
while True:
    ai = int(input())
    if ai == 0:
        break
    a.append(ai)
for i in range(len(a)):
    dp = [0] * (a[i] + 10)
    dp[0] = 1
    dp[1] = 1
    dp[2] = 2
    for j in range(3, a[i] + 1):
        dp[j] = dp[j - 1] + dp[j - 2] + dp[j - 3]
    #print(dp)
    print(math.ceil(dp[a[i]] / 3650))

Submission status: Accepted

Solution code:
import unittest
from io import StringIO

import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    L=[]
    while True:
        x=int(input())
        if x!=0:
            L.append(x)
        else: break
    M=max(L)


    # https://qiita.com/drken/items/dc53c683d6de8aeacf5a#dp-%E5%AE%9F%E8%A3%85%E3%81%AE%E9%A0%86%E5%BA%8F
    
    
    # dpテーブル dp[i]:= i段目まで登るための通り数
    dp = [0]*(M+1)
    """
    初期化の値は，
        最小化問題：INF, 
        最大化問題：-INF（0以上の値しか取らないなら-1, あるいは0でもいいかも)
        数え上げ問題：0
        確率問題：0
        Yes/No判定問題:False
    """
    
    # 初期条件
    dp[0] = 1
    
    # ループ
    for i in range(1,M+1):
    
        """
        dp[from] の値の更新が完了していればノード from からノード to への緩和を行っていい．貰うdpであれ配るdpであれ．
        両者の違いを意識すべきケースはcf. 
        https://qiita.com/drken/items/ace3142967c4f01d42e9#%E8%B2%B0%E3%81%86-dp-%E3%81%A8%E9%85%8D%E3%82%8B-dp-%E3%81%AE%E6%AF%94%E8%BC%83
        """
    
        dp[i]+=dp[i-1]
        if i>=2:
            dp[i]+=dp[i-2]
        if i>=3:
            dp[i]+=dp[i-3]
        
        
    
    # 出力
    
    for i in L:
        print(-(-dp[i] // 3650))
        
        
resolve()

Submission status: Accepted

Solution code:
def resolve():
	do = True
	while do:
		s = int(input())
		if not s:
			break
		dp = [-1]*(s+1)
		for i in range(s+1):
			if i == 0 or i == 1:
				dp[i] = 1
				continue
			t = []
			for j in range(1, 4):
				if i - j >= 0:
					t.append(dp[i-j])
			dp[i] = sum(t)
		r = 1 if dp[-1] % (10*365) else 0
		print(dp[-1] // (10*365) + r)
resolve()

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    dp = [0] * (n + 1)
    dp[0] = 1
    if n <= 3:
        print(1)
    else:
        dp[1] = 1
        dp[2] = 2
        for i in range(3, n + 1):
            dp[i] = dp[i - 3] + dp[i - 2] + dp[i - 1]
        print(dp[-1] // (365 * 10) + 1)

Submission status: Accepted

Solution code:
'''
DPで解く
'''
# DPテーブル
dp = [0] * 31

# 初期値
dp[0] = 1
dp[1] = 1
dp[2] = 2

# dp[30]までの値を記録
for i in range(3, 31):
    dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3]

while True:
    n = int(input())
    if n == 0:
        break
    # 解を出力
    ans = 1 + dp[n] // (365 * 10)
    print(ans)

Submission status: Accepted

Solution code:
import math

# 1年での試行回数
Y = 365*10

# dpテーブル初期化
dp = [0]*(30+1)
dp[0] = 1
dp[1] = 1
dp[2] = 2

# dpテーブル作成
for i in range(3, 31):
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3]

# 終了フラグ
flag = 0

# dpテーブル更新のindexの最大値を記録
i_max = 2

while flag == 0:
    floor = int(input())
    if floor == 0 :
        # 終了する
        flag = 1
    else:
        print(math.ceil(dp[floor]/Y))

Submission status: Accepted

Solution code:

def dpf(n):
    dp = [-1]*40
    dp[0] = 1
    dp[1] = 1
    dp[2] = 2

    for i in range(3, n+1):
        dp[i] = dp[i-1] + dp[i-2] + dp[i-3]

    return dp[n]

def solve(i):
    res = -1
    x = dpf(i)    
    day = (x+10-1)//10
    res = (day+365-1)//365
    return res

def main():
    a = []
    for e in iter(input, '0'):
       a.append(int(e)) 

    for i in a:
        print(solve(i))
    
main()

Submission status: Accepted

Solution code:

def stairs(N):
    dp = [0] * (N + 5)
    dp[0] = 1
    for i in range(N + 1):
        dp[i + 1] += dp[i]
        dp[i + 2] += dp[i]
        dp[i + 3] += dp[i]

    d, v = divmod(dp[N], 10)
    days = d + 1 if v else d
    d, v = divmod(days, 365)
    years = d + 1 if v else d
    print(years)


while True:
    N = int(input())
    if N == 0:
        exit()
    stairs(N)

Submission status: Accepted

Solution code:
while True:
    N = int(input())
    if N == 0:
        exit()
    elif N == 1:
        print(1)
    elif N == 2:
        print(1)
    else:
        dp = [0 for i in range(0, N+1)]
        dp[0] = 1
        dp[1] = dp[0]
        dp[2] = dp[0]+dp[1]
        for i in range(3, N+1):
            dp[i] = dp[i-3]+dp[i-2]+dp[i-1]
        ans = dp[N]//3650
        if dp[N] % 3650 == 0:
            print(ans)
        else:
            print(ans+1)

Submission status: Accepted

Solution code:
dp = [0]*(31)
dp[0] = 0
dp[1] = 1
dp[2] = 2
dp[3] = 4
ans = [0]*31
ans[1] = 1
ans[2] = 1
ans[3] = 1 
input_line = [-1]*31
for i in range(4,31):
    dp[i] += dp[i-1]+dp[i-2]+dp[i-3]
    if dp[i]%10==0:
        ans[i] = dp[i]//10
    else:
        ans[i] = dp[i]//10+1
for i in range(31):
    if ans[i] % 365 == 0:
        ans[i] = ans[i]//365
    else:
        ans[i] = ans[i]//365+1
for i in range(31):
    input_line[i] = int(input())
    if input_line[i] == 0:
        end = i
        break
for i in range(end):
    print(ans[input_line[i]])

Submission status: Accepted

Solution code:
from math import ceil

INF = int(1e18)
DP = [INF for _ in range(32)]
DP[1] = 1
DP[2] = 1
DP[3] = 2
for i in range(4, 32):
    DP[i] = DP[i - 1] + DP[i - 2] + DP[i - 3]

# print(DP[1:])
while True:
    n = int(input())
    if n == 0:
        break

    print(ceil(DP[n + 1] / 3650))

Submission status: Accepted

Solution code:
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

a = []
while True:
	n = int(input())
	if n == 0:
		break
	a.append(n)

N = max(a)
dp = [0 for _ in range(N+1)]
dp[0] = 1

for i in range(N+1):
	for j in range(1,4):
		if i+j >= N+1:
			break
		dp[i+j] += dp[i]

for ans in a:
	print((int((dp[ans]/10)//365))+1)

Submission status: Accepted

Solution code:
import math
while True:
    n=int(input())
    if n==0:
        break
    elif n>=4:
        dp=[0]*n
        dp[0]=1
        dp[1]=2
        dp[2]=4
        for i in range(3,n):
            dp[i]=dp[i-1]+dp[i-2]+dp[i-3]
        print(int(math.ceil(dp[n-1]/10/365)))
    else:
        print(1)

Submission status: Accepted

Solution code:
import math

def cal_pattern(n):
  dp = [0]*(n+1)
  dp[0] = 1
  dp[1] = 1
  if n == 1: return dp[-1]
  dp[2] = 2
  for i in range(3, n+1):
    dp[i] = dp[i-1]+dp[i-2]+dp[i-3]
  return dp[-1]

def run(n):
  patterns = cal_pattern(n)
  days = math.ceil(patterns/10)
  print(math.ceil(days/365))
  
if __name__ == '__main__':
  while True:
    n = int(input())
    if n == 0: break
    run(n)

Submission status: Accepted

Solution code:
def main():
    from math import ceil
    N = int(input())
    while N != 0:
        dp = [0] * (N+1)
        dp[0] = 1
        for i in range(1, N + 1):
            res = 0
            for j in range(1, 4):
                if i-j < 0:
                    continue
                res += (dp[i - j])
            dp[i] = res
        print(ceil(ceil(dp[-1]/10) / 365))
        N = int(input())


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math

a = []
while True:
    n = int(input())
    if n == 0:
        break
    a.append(n)

for n in a:
    dp = [0] * (n + 1)
    dp[0] = 1
    for i in range(n + 1):
        if i > 0: dp[i] += dp[i - 1]
        if i > 1: dp[i] += dp[i - 2]
        if i > 2: dp[i] += dp[i - 3]
    
    print(int(math.ceil(dp[n] / (365 * 10))))

Submission status: Accepted

Solution code:
import math
N = []
while 1:
    n = int(input())
    if n == 0:
        break
    N.append(n)
# print(N)

for n in N:
    dp = [0]*(n+5)
    dp[0] = 1
    for i in range(n):
        dp[i+1] += dp[i]
        dp[i+2] += dp[i]
        dp[i+3] += dp[i]
    print(math.ceil(dp[n]/3650))

Submission status: Accepted

Solution code:
b=True
l=[1,1,2,4]
def year(n):
  if n%3650==0:
    return n//3650
  else:
    return n//3650+1
while b==True:
  n=int(input())
  if n==0:
    b=False
    break
  else:
    if len(l)>n:
      pass
    else:
      while len(l)!=1+n:
        l.append(l[-1]+l[-2]+l[-3])
    print(year(l[n]))

Submission status: Accepted

Solution code:
l = [ 0 for i in range(33)]
l[0] = 1
l[1] = 1

def f(n):
    if n == 2:
        if l[n] != 0:
            return l[2]
        else:
            l[2] = l[0] + l[1]
            return l[0] + l[1]
    elif n < 2:
        return l[n]
    else:
        if l[n] != 0:
            return l[n]
        else:
            l[n] = f(n-1) + f(n-2) + f(n-3)
            return l[n]
        
while True:
    n = int(input())
    if n == 0:
        exit()
    else:

        print(f(n)//3650+1)

Submission status: Accepted

Solution code:
A=[1,2,4]
for i in range(3,30):
  A.append(A[i-1]+A[i-2]+A[i-3])

while True:
  n=int(input())
  if n==0:
    break
  print(A[n-1]//3650+1)

Submission status: Accepted

Solution code:
import functools
@functools.lru_cache(maxsize=30)
def f(n):
  if n==1:
    return 1
  elif n==2:
    return 2
  elif n==3:
    return 4
  else:
    return f(n-1)+f(n-2)+f(n-3)
while True:
  n=int(input())
  if n==0:
    break
  if n<=10:
    print("1")
  else:
    if f(n)%10==0:
      if (f(n)//10)%365==0:
        print((f(n)//10)//365)
      else:
        print(((f(n)//10)//365)+1)
    else:
      if ((f(n)+1)//10)%365==0:
        print(((f(n)+1)//10)//365)
      else:
        print((((f(n)+1)//10)//365)+1)

Submission status: Accepted

Solution code:
import functools

@functools.lru_cache(maxsize = 30)
def f(n) :
      if(n == 1) :
        return 1
      elif(n == 2) :
        return 2
      elif(n == 3) :
        return 4
      else :
        return f(n - 1) + f(n - 2) + f(n - 3)
      
while True :
  n = int(input())
  if(n == 0) :
    break
  else :
    if(f(n) % 10 == 0) :
      x = f(n) // 10
    else :
      x = f(n) // 10 + 1
    
    if(x % 365 == 0) :
      s = x // 365
    else :
      s = x // 365 + 1
     
    print(s)

Submission status: Accepted

Solution code:
while True:
  n = int(input())
  if n==0:
    break
  dp = [1,2,4]
  for i in range(3,n):
    dp.append(dp[i-3]+dp[i-2]+dp[i-1])
  day = (dp[n-1]-1)//10+1
  year = (day-1)//365+1
  print(year)

Submission status: Accepted

Solution code:
def kannon(n):
    a = [1]
    for i in range (1,n+1):
        a.append(a[i-1])
        if i >= 2:
            a[i] += a[i-2]
        if i >= 3:
            a[i] += a[i-3]
    return (a[-1] -1)//3650 + 1

while True:
    n = int(input())
    if n==0:
        break
    print(kannon(n))

Submission status: Accepted

Solution code:
import math
 
ans = [0 for i in range(31)]
ans[0] = 1
ans[1] = 1
ans[2] = 2
for i in range(3, 31):
    ans[i] = ans[i-1] + ans[i-2] + ans[i-3]
 
while True:
    N = int(input())
    if N == 0:
        break
 
    print(math.ceil(ans[N]/3650))

Submission status: Accepted

Solution code:
dp = [0]*31
dp[0] = 1
dp[1] = 1
dp[2] = 2
dp[3] = 4
for i in range(4,31):
    dp[i] = dp[i-1]+dp[i-2]+dp[i-3]
while True:
    n = int(input())
    if n == 0:
        exit()
    else:
        if dp[n]%3650 == 0:
            print(dp[n]//3650)
        else:
            print(dp[n]//3650+1)

Submission status: Accepted

Solution code:
for i in range(30):
    n = int(input())
    if n == 0:
        break

    INF = 105 * 10 ** 7
    dp = [0] * 100010

    dp[0] = 1
    dp[1] = 2
    dp[2] = 4

    for i in range(3, n):
        dp[i] = dp[i-1] + dp[i-2] + dp[i-3]

    years = dp[n-1] // 3650  + 1 if dp[n-1] % 3650 else dp[n-1] // 3650
    print(years)

Submission status: Accepted

Solution code:
for i in range(31):
    n = int(input())
    if n == 0:
        break

    d = [1, 1, 2, 4]
    for i in range(4, n+1):
        d.append(d[i-3] + d[i-2] + d[i-1])

    q, r = divmod(d[n], 3650)

    print(q if r == 0 else q + 1)

Submission status: Accepted

Solution code:
dp = [0]*31
#print(dp)

dp[0] = 1
dp[1] = 1
dp[2] = 2

for i in range(3,31):
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3]

while True:
    n = int(input())
    if n == 0:
        break
    print(dp[n]//(365*10) + 1)

Submission status: Accepted

Solution code:
def calc_term(num,size):
  term = num // size
  if num % size != 0:
    term += 1
  return term

def main():
  ary = [0] * 40
  while True:
    n = int(input())
    if n == 0:
      break
    ary[0] = 1
    ary[1] = 1
    ary[2] = 2
    for i in range(3,n+1):
      ary[i] = ary[i-3] + ary[i-2] + ary[i-1]
    days = calc_term(ary[n],10)
    years = calc_term(days,365)
    print(years)

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
def inpl(): return list(map(int, input().split()))

while True:
    tmp = int(input())
    if tmp == 0:
        break
    
    A = [0] * tmp
    A[0] = 1
    if tmp > 1:
        A[1] = A[0] + 1
    if tmp > 2:
        A[2] = A[1] + A[0] + 1
    for i in range(3, tmp):
        A[i] = A[i-3] + A[i-2] + A[i-1]
    print(-(-1*A[-1]//(10*365)))

Submission status: Accepted

Solution code:
stair = [1, 1, 2]
for i in range(3, 31):
    stair.append(stair[i-1] + stair[i-2] + stair[i-3])

while 1:
    n = int(input())
    if n == 0:
        break

    print((stair[n]+3649) // 3650)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0: break
    a = list(range(n+1))
    a[:4] = [1, 1, 2, 4]
    for i in range(4, n+1):
        a[i] = a[i-1] + a[i-2] + a[i-3]
    print(a[n]//3650 + bool(a[n]%3650))

Submission status: Accepted

Solution code:
#coding:utf-8
from __future__ import division,print_function
try:
    input = raw_input
    range = xrange
except NameError:
    pass
# 上記のコードはPython2とPython3の違いを一部吸収するためのもの

# def solve(n):
# n : 段数(整数)
# 出力: 一郎君がすべての上り方を実行するのに必要な年数をprintする。
a=[0]*100
def solve(n):
    # ここに問題を解くプログラムをかく。s(4)==s(1)*4+s(2)*2+s(3)*1
    if n==1:
        a[1]=1
        return 1
    elif n==2:
        a[2]=2
        return 2
    elif n==3:
        a[3]=4
        return 4
    elif a[n]!=0:
        return a[n]
    else:
        a[n]=solve(n-3)+solve(n-2)+solve(n-1)
        return a[n]
    

def main():
    while True:
        inp=int(input())
        if inp==0:
            break
        print(solve(inp)//3650+1)

main()

Submission status: Runtime Error

Solution code:
def fib(n):
    n=int(n)
    F=[1,1,2]
    if n>=3:
        for j in range(2,n):
            F.append(F[j-2]+F[j-1]+F[j])
    return F[n]
                
for i in range(32):
    a=input(int())
    if a==0:
        break
    else:
        print(-((-fib(a)//10)//365))
    
    
    
#https://python.ms/sub/misc/division/を参考にしました

Submission status: Runtime Error

Solution code:
def fib(n):
    n=int(n)
    F=[1,1,2]
    if n>=3:
        for j in range(2,n):
            F.append(F[j-2]+F[j-1]+F[j])
    return F[n]
                
a=input(int())
if a==0:
    break
else:
    print(-((-fib(a)//10)//365))

Submission status: Runtime Error

Solution code:
def fib(n):
    n=int(n)
    F=[1,1,2]
    if n>=3:
        for j in range(2,n):
            F.append(F[j-2]+F[j-1]+F[j])
    return F[n]
                
a=input(int())
    print(-((-fib(a)//10)//365))

Submission status: Runtime Error

Solution code:
#???????????\?????¨??????????????????????????°???
a = [1, 2, 4]
MAX_N = 30
for i in xrange(3, MAX_N+1):
    a.append(a[i-3] + a[i-2] + a[i-1])

while True:
    n = input()
    if n == 0:
        break
    else:
        print a[n-1] / 3650 + 1

Submission status: Runtime Error

Solution code:
a = []
a[:4] = [0, 1, 2, 3]
inList = []
while True:
    price = int(input())
    if price == 0:
        break
    inList.append(int(input()))
n = max(inList)
for i in range(4, n + 1):
    a[i] = a[i-1] + a[i-2] + a[i-3]
for i in inList:
    print((a[i] // 3650) + (a[i] % 3650 != 0))

Submission status: Runtime Error

Solution code:
a = []
a[:4] = [0, 1, 2, 3]
inList = []
while True:
    n = int(input())
    if n == 0:
        break
    inList.append(n)
n = max(inList)
for i in range(4, n + 1):
    a[i] = a[i-1] + a[i-2] + a[i-3]
for i in inList:
    print((a[i] // 3650) + (a[i] % 3650 != 0))

Submission status: Runtime Error

Solution code:
while 1:
    n = int(input())
    if n == 0:break
    A = [1 for _ in range(30)]
    for i in range(1, n + 1):
        A[i] = A[i - 1]
        if i > 1:
            A[i] += A[i - 2]
        if i > 2:
            A[i] += A[i - 3]
    print(A[n] // 3650 + 1)

Submission status: Runtime Error

Solution code:
#coding:utf-8
from __future__ import division,print_function
try:
    input = raw_input
except NameError:
    pass
# 上記のコードはPython2とPython3の違いを一部吸収するためのもの
memo=[0]*31
def solve(x):
    if memo[x]==0:
        if x>1:
            memo[x]=solve(x-1)+solve(x-2)+solve(x-3)
            return memo[x]
        elif x==0:
            memo[x]=1
            return 1
        else:
            return 0
    else:
        return memo[x]

def main():
    while True:
        inp=input()
        if inp==0:
            break
        print(solve(inp))

main()

Submission status: Runtime Error

Solution code:
import sys, math
step = [1,1,2,4] + [0]*26
for i in range(4,30):
  step[i] = step[i-1] + step[i-2] + step[i-3]

for s in sys.stdin:
  n = int(s)
  if n == 0: break
  print int(math.ceil(step[n]/3650.0))

Submission status: Runtime Error

Solution code:
import sys, math
step = [1,1,2,4] + [0]*26
for i in range(4,31):
  step[i] = step[i-1] + step[i-2] + step[i-3]

for s in sys.stdin:
  n = int(s)
  if n == 0: break
  print int(math.ceil(step[n]/3650.0))

Submission status: Runtime Error

Solution code:
import math
step = [1,1,2,4] + [0]*27
for i in range(4,31):
  step[i] = step[i-1] + step[i-2] + step[i-3]

while True:
  n = int(s)
  if n == 0: break
  print int(math.ceil(step[n]/3650.0))