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

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

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

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

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

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

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

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

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

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

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

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

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

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

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+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 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: #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()

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

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

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

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