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

C++: #include <iostream>

using namespace std;
int dp[32];

void solve()
{
	dp[0] = 1;
	dp[1] = 2;
	dp[2] = 4;
	for(int i = 3; i < 30; ++i)
	{
		dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
	}
	int n;
	while(cin >> n, n)
	{
		cout << dp[n - 1] / 3650 + 1 << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n;
    int a[15000] = {0};
    while(scanf("%d",&n)!=EOF){
    int ans = 0;
    a[0] = 1;
    a[1] = 1;
    a[2] = 2;
    for(int i = 3;i <= n; i++){
        a[i] = a[i-1] + a[i-2] + a[i-3];
    }
    ans = a[n]/3650;
    printf("%d\n",ans+1);
    }
    return 0;
}