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 <bits/stdc++.h> 

using namespace std;
#define MAX_N 31

/*
#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define LLINF LLONG_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
*/

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input values
    vector<int> vec;
    int i = 0;
    for (i = 0; i < MAX_N; i++) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        vec.push_back(n);
    }

    // dp table
    vector<int> dp(MAX_N, 0);

    // init dp table
    // ok

    // init condition
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;

    // loop
    for (i = 0; i < MAX_N; i++) {
        dp[i+3] = dp[i]+dp[i+1]+dp[i+2];
    }

    for (i = 0; i < vec.size(); i++) {
        cout << dp[vec[i]]/3650+1 << endl;
    }
    return 0;
}

C++: #include <iostream>

const int kMaxJumpStep = 3;

int dp(const int N){
	int step[31];
	step[0] = 1;

	for (int i = 0; i <= N; i++){
		for (int j = i + 1; j <= i + kMaxJumpStep; j++){
			if (j > N) break;
			step[j] += step[i];
		}
	}

	return step[N];
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	while (1){
		int n;
		std::cin >> n;
		if (n == 0) break;
		std::cout << dp(n)/3650 + 1 << std::endl;
	}

	return 0;
}

C++: /*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.16f\n", a)//少数出力
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {

	int n;
	scanf("%d", &n);
	while (n) {
		vector<ll> dp(n + 3);
		dp[0] = 1;
		rep(i, n) {
			dp[i + 1] += dp[i];
			dp[i + 2] += dp[i];
			dp[i + 3] += dp[i];
		}
		dp[n] = ceil(dp[n] / (double)10);
		dp[n] = ceil(dp[n] / (double)365);
		printf("%lld\n", dp[n]);
		scanf("%d", &n);
	}

	return 0;
}

C++: #include <iostream>
using namespace std;

int num(int n);

int main()
{
  string s;
  cin >> s;
  int n = stoi(s)
  cout << num(n) <<endl;
}

int num(int n){
  if(n<0)return 0;
  return num(n-1)+num(n-2)+num(n-3);
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include<cstdio>
#include<algorithm>

#define N_MAX 30

int main(){
	while (1){
		int n, dp[N_MAX + 1];
		scanf("%d", &n);
		if (n == 0)
			break;
		std::fill(dp, dp + n + 1, 0);
		dp[0] = 1;
		dp[1] = 1;
		dp[2] = 2;
		for (int i = 3; i <= n; ++i){
			for (int j = 1; j <= 3; ++j){
				if (j <= i){
					dp[i] += dp[i - j];
				}
			}
		}
		int day = (dp[n] % 3650 == 0) ? dp[n] / 3650 : dp[n] / 3650 + 1;
		printf("%d\n", day);
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <bitset>
#include <cstring>
#include <string>


using namespace std;
typedef long long int ll;
typedef vector<int>  VI;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))

long int takakuwa[50];

int a(int i){
	if(i<0) return 0;
	return takakuwa[i];
}

void solve(){
	takakuwa[0] =1;
	REP(i,30){
		takakuwa[i+1] += takakuwa[i];
		takakuwa[i+2] += takakuwa[i];
		takakuwa[i+3] += takakuwa[i];
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	/*
	int n;
	cin >>n;
	for(int i;i<n;i++){
		cin >>;
	}
	*/

	solve();
	int n;
	while(cin >>n){
		if(n==0)return 0;
		cout << (takakuwa[n]-1)/(10*365) +1 <<endl;
		}	
	return 0;
}

C++: #include <iostream>
using namespace std;

int main(){
	int n, ans;
	long long int root[40] = {}, day[31] = {};
	root[0] = 1;
	root[1] = 1;
	root[2] = 2;
	for(int i = 3;i<40;i++){
		root[i] = root[i - 1] + root[i - 2] + root[i - 3];
	}
	for(int i = 0;i<40;i++){
		day[i] = root[i] / 10;
		if(root[i] % 10 > 0){
			day[i]++;
		}
	}
	while(cin >> n){
		if (n == 0) break;
		ans = 0;
		if (day[n] > 0) ans++;
		ans += day[n] / 365;
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
	int p[31];
	p[0] = 1;
	p[1] = 1;
	p[2] = 2;
	for (int i = 3; i <= 30; ++i)
	{
		p[i] = p[i-1] + p[i-2] + p[i-3];
	}
	while(1){
		int y, n;
		cin >> n;
		if(n == 0){
			break;
		}
		y = p[n] / 10 / 365 + 1;
		
		cout << y << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;

int main()
{
	int n;
	while(cin >> n){
		if(!n)
			break;
		int DP[31];
		DP[0] = 1;
		DP[1] = 1;
		DP[2] = 2;
		for(int i=3;i<=n;i++){
			DP[i] = DP[i-1]+DP[i-2]+DP[i-3];
		}
		int ans = DP[n]/10;
		if(DP[n]%10!=0)
			ans++;
		int answer = ans/365;
		if(ans%365!=0)
			answer++;
		cout << answer << endl;
	}
	return 0;
}