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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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