Go: package main

import (
	"bufio"
		"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	dp := make([]int , 30)
	dp[0] = 1 // 1段の階段の登り方
	dp[1] = 2 // 2段の階段の登り方
	dp[2] = 4 // 3段の階段の登り方
	for i := 3; i < 30; i++ {
		// n段の階段の登り方は
		// n-1段の階段の登り方+n-2段の階段の登り方+n-3段の階段の登り方
		dp[i] = dp[i-1]+dp[i-2]+dp[i-3] 
	}
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		fmt.Println(((dp[n-1]+9)/10+364)/365)
	}
}

Python: 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()

Python: 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)

Python: 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)

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

Python: 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)

Python: #!/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) )

Python: 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)

Python: 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))

Python: 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)

Python: 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)

Python: 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))

Python: #!/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()

Python: 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)

Python: 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)

Python: 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]))

Python: # -*- 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))

Python: 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)

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