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: Wrong Answer

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

Submission status: Wrong Answer

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(30):
    a=input(int())
    if a==0:
        break
    else:
        print(-((-fib(a)//10)//365))
    
    
    
#https://python.ms/sub/misc/division/を参考にしました

Submission status: Wrong Answer

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(30):
    a=input(int())
    if a==0:
        break
    else:
        print(-((-fib(a)//10)//365))

Submission status: Wrong Answer

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: Wrong Answer

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

while True:
    n = int(input())
    if not n:
        break
    print(((a[n] + 9) / 10 + 364) / 365)

Submission status: Wrong Answer

Solution code:
dp = [1] + [0 for i in range(30)]
for i in range(1,31):
	for step in [1,2,3]:
		if step <= i:
			dp[i] += dp[i-step]
unit = 365 * 10
while 1:
	n = int(raw_input())
	if n == 0:
		break
	print dp[n] / unit + 1 & (dp[n] % unit)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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=int(input())
        if inp==0:
            break
        print(solve(inp))

main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
def stairs(n):
    if (n == 1):
        return 1
    elif(n == 2):
        return 2
    elif(n == 3):
        return 4
    return stairs(n-1) + stairs(n-2) + stairs(n-3)
while (n != 0):
    pn = stairs(n)
    if (pn%10 == 0):
        pn //= 10
    else:
        pn = pn//10 + 1

    if (pn%365 == 0):
        pn //= 365
    else:
        pn = pn//365 + 1
    print(pn)
    n = int(input())

Submission status: Time Limit Exceeded

Solution code:
import math

def f(n):
    global res
    for i in range(1, 4):
        if n-i == 0:
            res += 1
        elif 0 < n-i:
            f(n-i)

while True:
    n = input()
    if n == 0: break
    res = 0
    f(n)
    res = math.ceil(float(res)/10)
    if res <= 365:
        print 1
    else:
        print int(math.ceil(res/365))

Submission status: Time Limit Exceeded

Solution code:
import math, sys
sys.setrecursionlimit(20000)

def f(n):
    global res
    for i in range(1, 4):
        if n-i == 0:
            res += 1
        elif 0 < n-i:
            f(n-i)

while True:
    n = input()
    if n == 0: break
    res = 0
    f(n)
    res = math.ceil(float(res)/10)
    if res <= 365:
        print 1
    else:
        print int(math.ceil(res/365))

Submission status: Time Limit Exceeded

Solution code:
import functools


#@functools.lru_cache(maxsize=None)
def rec(i):
    if i <= 0:
        return i == 0
    return rec(i-1) + rec(i-2) + rec(i-3)

while True:
    N = int(input())
    if not N:
        break
    print(((rec(N)-1)//10)//365+1)

Submission status: Time Limit Exceeded

Solution code:
def tribonacci(n):
    if n == 0:
        return 1
    if n == 1:
        return 1
    if n == 2:
        return 2
    else:
        return tribonacci(n-1)+tribonacci(n-2)+tribonacci(n-3)
    
while True:
    n = int(input())
    if n == 0:
        break
    print((tribonacci(n)//(365*10))+1)

Submission status: Time Limit Exceeded

Solution code:
def up(n):
	if n == 0: return 1
	if n < 0: return 0
	return up(n-1)+up(n-2)+up(n-3)
	
while True:
	n = int(raw_input())
	if n == 0: break
	print (up(n)//10+1)//365+1

Submission status: Accepted

Solution code:
n = int(input())
st = [1,2,4]
for i in range(n-3):
    s = st[-1] + st[-2] + st[-3]
    st.append(s)
while (n != 0):
    pn = st[n-1]
    if (pn%10 == 0):
        pn //= 10
    else:
        pn = pn//10 + 1

    if (pn%365 == 0):
        pn //= 365
    else:
        pn = pn//365 + 1
    print(pn)
    n = int(input())
    st = [1,2,4]
    for i in range(n-3):
        s = st[-1] + st[-2] + st[-3]
        st.append(s)

Submission status: Accepted

Solution code:
def NtoY(N):
    D = (N-1)//10 + 1
    Y = (D-1)//365 + 1
    return(Y)

while True:
    n = int(input().strip())
    if n == 0:
        break
    elif n == 1:
        print(NtoY(1))
    elif n == 2:
        print(NtoY(2))
    else:
        lst = [0 for i in range(0,n+1)]
        lst[0] = 1
        lst[1] = 1
        lst[2] = 2
        for i in range(0,n-2):
            lst[i+3] = lst[i+2] + lst[i+1] + lst[i]
        print(NtoY(lst[n]))

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-3] + dp[i-2] + dp[i-1]

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

dp = [1 if i == 0 else 0 for i in range(34)]

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

while True:
    n = int(input())

    if n == 0:
        break

    print( int(dp[n] / 3650) if (dp[n] % 3650 == 0) else int(dp[n] / 3650 + 1) )

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile


def read(
    f, *shape, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[fill_value]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    dp = arr(31)
    dp[0], dp[1], dp[2] = 1, 1, 2
    for i in range(3, 31):
        dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3]
    while True:
        n = read(int)
        if n == 0:
            break
        print(dp[n] // 10 // 365 + 1)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

dp = [0,1,2,4]
for j in range(3,30):
    dp.append(dp[j]+dp[j-1]+dp[j-2])

for i in range(30):
    n = int(input())
    if n==0:
        break
    else:
        print(math.ceil(dp[n]/3650))

Submission status: Accepted

Solution code:
dp = [0 for i in range(31)]
dp[0] = 0
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:
    break
  if dp[n] % 3650 == 0:
    print(dp[n] // 3650)
  else:
    print(dp[n] // 3650 + 1)

Submission status: Accepted

Solution code:
while 1:
    n = int(raw_input())
    if (n == 0):
        break
    num = 0

    if (n == 1):
        num = 1
    if (n == 2):
        num = 2
    if (n == 3):
        num = 4
    if (n > 3):
        a1 = 1
        a2 = 2
        a3 = 4
        for i in range(n - 3):
            num = a1 + a2 + a3
            a1 = a2
            a2 = a3
            a3 = num
    
    years = num % 3650
    if (years != 0):
        years = 1
    years = years + num / 3650
    
    print years

Submission status: Accepted

Solution code:
a = [1]
for i in range(1, 31):
    a.append(sum(a[-3:]))

while True:
    n = int(input())
    if not n:
        break
    print(((a[n] + 9) // 10 + 364) // 365)

Submission status: Accepted

Solution code:
import math
N = []
while 1:
  x = input()
  if x==0: break
  N.append(x)
n0 = max(N)
A = [0]*(n0+1)
A[0:3]=[1,1,2]
for i in range(0,n0-2): A[i+3]=sum(A[i:i+3])
for e in N: print int(math.ceil(A[e]/3650.0))

Submission status: Accepted

Solution code:
N = []
while 1:
  x = input()
  if x==0: break
  N.append(x)
n0 = max(N)-2
A = [1,1,2]+[0]*n0
for i in range(0, n0): A[i+3] = sum(A[i:i+3])
for e in N: print A[e]/3650+[0,1][A[e]%3650>0]

Submission status: Accepted

Solution code:
N = []
while 1:
  x = int(raw_input())
  if x==0: break
  N.append(x)
n0 = max(N)-2
A = [1,1,2]+[0]*n0
for i in range(0, n0): A[i+3] = sum(A[i:i+3])
for e in N: print (A[e]+3649)/3650

Submission status: Accepted

Solution code:
from math import ceil
step = [1,2,3]
unit = 3650.
while 1:
	n = int(raw_input())
	if n == 0:
		break
	dp = [0 for i in range(n+1)]
	dp[0] = 1
	for i in range(1,n+1):
		for j in step:
			if j <= i:
				dp[i] += dp[i-j]
	print int(ceil(dp[n] / unit))

Submission status: Accepted

Solution code:
from math import ceil
dp = [1] + [0 for i in range(30)]
for i in range(1,31):
	for step in [1,2,3]:
		if step <= i:
			dp[i] += dp[i-step]
unit = 3650.
while 1:
	n = int(raw_input())
	if n == 0:
		break
	print int(ceil(dp[n] / unit))

Submission status: Accepted

Solution code:
from math import ceil
dp = [1] + [0 for i in range(33)]
for i in range(0,30):
	for step in [1,2,3]:
		dp[i+step] += dp[i]
unit = 3650.
while 1:
	n = int(raw_input())
	if n == 0:
		break
	print int(ceil(dp[n] / unit))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

dp = [0 for i in range(31)]
dp[1] = 1
dp[2] = 1
dp[3] = 1

for i in range(1,31):
    for j in range(1,4):
        if i-j > 0:
            dp[i] += dp[i-j]

while True:
    N = int(raw_input())
    if N == 0:
        break
    print(int(dp[N]/10//365)+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    M = Matrix2([[0, 1, 0], [0, 0, 1], [1, 1, 1]])
    F = [1, 2, 4]
    while True:
        n = int(raw_input())
        if n == 0:
            break
        if n <= 3:
            print 1
            continue
        m = M ** (n-3)
        print 1 + (F[0]*m[2][0] + F[1]*m[2][1] + F[2]*m[2][2]) / 10 / 365

class Matrix2(list):

    def __init__(self, m):
        list.__init__(self, [r[:] for r in map(list, m)])
        self.N = len(m)

    @classmethod
    def normal(self, n):
        return Matrix2([[0 if i != j else 1 for j in xrange(n)] for i in xrange(n)])

    @classmethod
    def zero(self, n):
        return Matrix2([[0] * n for _ in xrange(n)])

    def __mul__(self, other):
        ret = Matrix2.zero(self.N)
        for i in xrange(self.N):
            for j in xrange(self.N):
                for k in xrange(self.N):
                    ret[i][j] += self[i][k] * other[k][j]
        return ret

    def __repr__(self):
        return "[" + "\n ".join(map(str, self)) + "]"

    def _pow2(self):
        return self.__mul__(self)

    def __pow__(self, n):
        if n == 0:
            return Matrix2.normal(self.N)
        if n == 2:
            return self._pow2()
        res = Matrix2.normal(self.N)
        x = Matrix2(self)
        while n != 0:
            if (n & 1) == 1:
                res = res * x
            x = x ** 2
            n >>= 1
        return res

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

steps = []
step = int(input())
while step != 0:
    steps.append(step)
    step = int(input())

max_step = max(steps)
nums = [1,2,4] + [0 for _ in range(3,max_step)]
for i in range(3,max_step):
    nums[i] = nums[i-1] + nums[i-2] + nums[i-3]

for step in steps:
    year_minus = nums[step-1] // -3650
    print(str(-year_minus))

Submission status: Accepted

Solution code:
def solve(n):
    def get_count(n):
        if n < 3:
            return [1, 2, 4][n-1]
        cnt = [0] * (n)
        cnt[0] = 1
        cnt[1] = 2
        cnt[2] = 4
        for i in xrange(3, n):
            cnt[i] += cnt[i-1] + cnt[i-2] + cnt[i-3]
        return cnt[n-1]
    cnt =  get_count(n)
    print (((cnt+9)/10) + 364) / 365

if __name__ == "__main__":
    import sys
    while True:
        n = int(raw_input())
        if not n:
            sys.exit()
        solve(n)

Submission status: Accepted

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: Accepted

Solution code:
import sys

dp = [0] * 31
dp[0] = dp[1] = 1
dp[2] = 2

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

for n in sys.stdin:
	n = int(n)
	if n == 0:
		break
	else:
		print((3649+dp[n])//3650)

Submission status: Accepted

Solution code:
from math import ceil

a = [0, 1, 2, 4] # n = 0 ??? 3 ????????§??°??????
while True:
    n = int(input())
    if n == 0:
        break
    for i in range(len(a), n+1):
        a.append(a[-3] + a[-2] + a[-1])
    print( int(ceil(a[n]/3650)) )

Submission status: Accepted

Solution code:
#!/usr/bin/env python

def solve(n):
    dp = [0] * (n + 10)
    dp[0] = dp[1] = dp[2] = 1
    for i in xrange(n):
        for j in range(3):
            dp[i+j+1] += dp[i]
    days = (dp[n-1] - 1) / 10 + 1
    years = (days - 1) / 365 + 1
    return years

while True:
    n = int(raw_input())
    if not n:
        break
    print solve(n)

Submission status: Accepted

Solution code:
import math
stage = int(input())
while True:
    ans = [0 for n in range(stage)]
    for n in range(stage):
        if n == 0:
            try:
                ans[0] += 1
                ans[1] += 1
                ans[2] += 1
            except:
                pass
        else:
            if n - 3 < 0:
                ans[n] = ans[n] + sum(ans[:n])
            else:
                ans[n] = sum(ans[n-3:n])
    print(math.ceil(ans[-1] / 3650))
    stage = int(input())
    if stage ==0:
        break

Submission status: Accepted

Solution code:
while 1:
    n=int(raw_input())
    if n==0:break
    if n==1:
        print(1)
        continue
    dp=[0]*(n+1)
    dp[0]=dp[1]=1
    dp[2]=2
    for i in xrange(2,n):
        dp[i+1]=dp[i]+dp[i-1]+dp[i-2]
    print(dp[n]/3650+1)

Submission status: Accepted

Solution code:
import functools


@functools.lru_cache(maxsize=None)
def rec(i):
    if i <= 0:
        return i == 0
    return rec(i-1) + rec(i-2) + rec(i-3)

while True:
    N = int(input())
    if not N:
        break
    print(((rec(N)-1)//10)//365+1)

Submission status: Accepted

Solution code:
import functools


@functools.lru_cache(maxsize=None)
def rec(i):
    if i <= 0:
        return i == 0
    return rec(i-1) + rec(i-2) + rec(i-3)

while True:
    N = int(input())
    if not N:
        break
    print(rec(N)//3650+1)

Submission status: Accepted

Solution code:
import functools, math


@functools.lru_cache(maxsize=None)
def rec(i):
    if i <= 0:
        return i == 0
    return rec(i-1) + rec(i-2) + rec(i-3)

while True:
    N = int(input())
    if not N:
        break
    print(int(math.ceil(rec(N)/3650)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=[1,1,2]
for i in range(3,31): a.append(sum(a[-3:]))
while 1:
    n=int(input())
    if n==0:break
    print((3649+a[n])//3650)

Submission status: Accepted

Solution code:
import sys

n=30
f=[1,1,2,4]
while len(f)<=n:
    f.append(f[-1]+f[-2]+f[-3])


while True:
    n=int(input())
    if n==0:
        sys.exit()

    day=f[n]

    if day%3650==0:
        print(int(day/3650))
    else:
        print(int(day/3650)+1)

Submission status: Accepted

Solution code:
n = 30
dan_lis = [0] * n
dan_lis[0] = 1
dan_lis[1] = 2
dan_lis[2] = 4
for i in range(n - 3):
    dan_lis[i + 3] = dan_lis[i + 2] + dan_lis[i + 1] + dan_lis[i]
while True:
    n = int(input())
    if n == 0:
        break
    ans = dan_lis[n - 1]/10/365
    print(int(ans + 1))

Submission status: Accepted

Solution code:
while True:
  n = int(input())
  if n == 0:
    break
  ls = [0 for i in range(50)]
  ls[0] = 1
  for i in range(30):
    ls[i+1] += ls[i]
    ls[i+2] += ls[i]
    ls[i+3] += ls[i]
  print( (ls[n] // 3650) + (ls[n] % 3650 != 0) )

Submission status: Accepted

Solution code:
# Aizu Problem 00168: Kannondou
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


p = [1, 1, 2] + [0] * 28
for i in range(3, 31):
    p[i] = sum(p[i-3:])


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168

"""
import sys
from sys import stdin
from math import ceil
input = stdin.readline


def solve(n):
    dp = [[0] * (n+1) for _ in range(n+1)]
    for i in range(min(n+1, 4)):
        dp[0][i] = 1

    for i in range(1, n+1):
        for j in range(n+1):
            if j <= i:
                dp[i][j] = 0
            else:
                t = 0
                for k in range(1, min(j, 4)):
                    t += dp[i-1][j-k]
                dp[i][j] = t

    total = 0
    for d in dp:
        total += d[-1]
    return total


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break

        result = solve(n)
        print(ceil(result / 365 / 10))


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168

"""
import sys
from sys import stdin
from math import ceil
input = stdin.readline


def solve(n):
    dp = [[0] * (n+1) for _ in range(n+1)]
    dp[0][0] = 1

    for i in range(1, n+1):
        for j in range(i, n+1):
            t = 0
            for k in range(1, min(j+1, 3+1)):
                t += dp[i-1][j-k]
            dp[i][j] = t

    total = 0
    for d in dp:
        total += d[-1]
    return total


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break

        result = solve(n)
        print(ceil(result / 365 / 10))


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168

"""
import sys
from sys import stdin
from math import ceil
input = stdin.readline

dp = 0
def solve(n):
    global dp
    dp = [[0] * (n+1) for _ in range(n+1)]
    dp[0][0] = 1

    for i in range(1, n+1):
        for j in range(i, n+1):
            t = 0
            for k in range(1, min(j+1, 3+1)):
                t += dp[i-1][j-k]
            dp[i][j] = t

    total = 0
    for d in dp:
        total += d[-1]
    return total


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break

        result = solve(n)
        print(ceil(result / 365 / 10))


if __name__ == '__main__':
    main(sys.argv[1:])

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) + (a[n] % 3650 != 0))

Submission status: Accepted

Solution code:
def nob(n):
    nob_h=[n+1]

    for i in range(n+1):
        if i==0 or i==1:
            nob_h.append(1)
        elif i==2:
            nob_h.append(2)
        elif i>2:
            nob_h.append(nob_h[i]+nob_h[i-1]+nob_h[i-2])


    days=int(nob_h[n+1]/10)

    year=int(days/365)+1

    print(year)

n=[]

while True:
    i=input()
    if i == "0":
        break
    n.append(i)

for i in range(len(n)):
    nob(int(n[i]))

Submission status: Accepted

Solution code:
MAXN = 30
dp = [0] * (MAXN+1)
dp[1] = 1
dp[2] = 2
dp[3] = 4
for i in range(4,MAXN+1):
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3]

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

Submission status: Accepted

Solution code:
LENGTH = 30


def calculate_step(length):
    step_list = [0] * (length + 1)
    step_list[1] = 1
    step_list[2] = 2
    step_list[3] = 4

    for lp in range(4, length + 1):
        total = sum(step_list[lp - 3:lp])
        step_list[lp] = total

    return step_list


step_list = calculate_step(LENGTH)
step_list = [int(item / 10 / 365 + 1) for item in step_list]

while True:

    step = int(input())

    if step == 0:
        break

    print(step_list[step])

Submission status: Accepted

Solution code:
import math
a = [1, 2, 4]
while len(a) < 30:
    a.append(sum(a[-3:]))

while True:
    n = int(input())
    if n == 0:
        quit()
    else:
        print(math.ceil(a[n-1] / 10 / 365))

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:
l = [0 for _ in range(31)]
l[1] = 1
l[2] = 2
l[3] = 4

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

while True:
    n = int(input())
    if n == 0:
        break
    else:
        t = l[n]
        if t % 10 == 0:
            d = t // 10
        else:
            d = t // 10 + 1
        if d % 365 == 0:
            print(d // 365)
        else:
            print(d // 365 + 1)

Submission status: Accepted

Solution code:
# AOJ 0168 Kannondou
# Python3 2018.6.18 bal4u

ans = [	0,  1,  2,  4,  7,  13,  24,  44,  81,  149, \
274,  504,  927,  1705,  3136,  5768,  10609,  19513,  35890,  66012, \
121415,  223317,  410744,  755476,  1389537,  2555757,  4700770,  8646064, \
15902591,  29249425, 53798080 ]

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

Submission status: Accepted

Solution code:
dp = [None] * 31
dp[0] = 1
dp[1] = 1
dp[2] = 2
def func(n):
  for i in range(3, n + 1):
    dp[i] = dp[i - 3] + dp[i - 2] + dp[i - 1]

func(30)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = [0]*30; b = [1,0,0];
for i in range(30):
    a[i] = sum(b)
    b.pop(); b.insert(0,a[i]);
while 1:
    n = input()
    if n==0: break;
    print ((a[n-1] if a[n-1]>=10 else 10)//10+364)//365

Submission status: Accepted

Solution code:
dp = [0] * 50
dp[0] = 1
for i in range(30):
  dp[i + 1] += dp[i]
  dp[i + 2] += dp[i]
  dp[i + 3] += dp[i]

while True:
  n = input()
  if n == 0:
    break
  print ((dp[n] + 9) / 10 + 364) / 365

Submission status: Accepted

Solution code:
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input
a=[1,1,2]
for i in range(3,31): a.append(a[i-1]+a[i-2]+a[i-3])
while True:
	n=int(raw_input())
	if n==0: break
	print((a[n]+3649)//3650)

Submission status: Accepted

Solution code:
def up(n):
	goal = [0 for i in range(n)]
	goal[:3] = [1,2,4]
	for i in range(3,n):
		goal[i] = sum(goal[i-3:i])
	return goal[-1]
	
while True:
	n = int(raw_input())
	if n == 0: break
	print (up(n)//10+1)//365+1

Submission status: Accepted

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>0:
            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=int(input())
        if inp==0:
            break
        print((solve(inp)-1)//3650+1)

main()

Submission status: Accepted

Solution code:
steps=[1,2,4]+ [0]*27
for i in range(3,30):
  steps[i]=steps[i-1]+steps[i-2]+steps[i-3]
while True:
  n=input()
  if n==0:break
  print steps[n-1]/10/365+1

Submission status: Accepted

Solution code:
import math

steps=[1, 1, 2, 4]+ [0]*27
for i in range(4, 31):
  steps[i]=steps[i-1]+steps[i-2]+steps[i-3]

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

Submission status: Accepted

Solution code:
import math

steps=[1, 1, 2, 4]+ [0]*27
for i in range(4, 31):
  steps[i] = steps[i-1] + steps[i-2] + steps[i-3]

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

Submission status: Accepted

Solution code:
import sys
if sys.version_info[0]>=3: raw_input=input
a=[1,1,2]
for i in range(3,31): a.append(a[i-1]+a[i-2]+a[i-3])
while True:
	n=int(raw_input())
	if n==0: break
	print((a[n]+3649)//3650)

Submission status: Accepted

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

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

    for i in range(1, n+1):
        dp[i] += dp[i-1]
        if i > 1:
            dp[i] += dp[i - 2]
        if i > 2:
            dp[i] += dp[i - 3]
    print((dp[-1]//10 + 1) // 365 + 1)

Submission status: Accepted

Solution code:
import sys,math
a=list(map(int,sys.stdin.read().split()))
a.pop(-1)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
    N=int(input())
    if N==0:break
        
    D=[0]*(N+1)
    D[0]=1

    for i in range(1,N+1):
     D[i]=(D[i-1]+D[i-2]+D[i-3])
    print( int(-((-D[-1]/10)//365)))

Submission status: Accepted

Solution code:
def solve():
    ans = []
    while True:
        n = int(input())
        if n == 0:
            break

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

        ans.append((dp[-1]+3649) // 3650)
    print(*ans, sep='\n')


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#演習2-5　Kannnondo
while True:
    n=int(input())
    if n==0:
        break
    else:
        A=[0]*40
        A[0],A[1],A[2]=1,1,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:
def stair(n) :
    if n == 1 :
        return 1
    elif n == 2 :
        return 2
    elif n == 3 :
        return 4
    elif n == 4 :
        return 7
    elif n == 5 :
        return 13
    elif n == 6 :
        return 24
    elif n == 7 :
        return 44
    elif n == 8 :
        return 81
    else :
        return stair(n-1)+stair(n-2)+stair(n-3)

while True :
    n = int(input())
    if n == 0 :
        break
    kaisu = stair(n)
    if kaisu % 10 == 0 :
        day = kaisu // 10
    else :
        day = kaisu // 10 + 1
    if day % 365 == 0 :
        year = day // 365
    else :
        year = day // 365 + 1
    print(year)

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:
def main():
    import sys

    readline = sys.stdin.readline

    while True:
        N = int(readline().rstrip())
        if N == 0:
            break

        dp = [0] * (N + 1)
        dp[0] = 1
        
        for i in range(1, N + 1):
            if i == 1:
                dp[i] += dp[i - 1]
            elif i == 2:
                dp[i] += dp[i - 1] + dp[i - 2]
            else:
                dp[i] += dp[i - 1] + dp[i - 2] + dp[i - 3]
        print(-(-dp[-1] // 3650))


main()

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:
def solve(N):
    dp = [0] * (N + 1)

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

    d = (dp[N] // 10 + int(dp[N] % 10 != 0))
    print(d // 365 + int(d % 365 != 0))


N = int(input())
while N != 0:
    solve(N)
    N = int(input())