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++: #define rep(i, n) for(int i = 0; i < (int)n; i++)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // ユークリッドの互除法（aが長辺）
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}          // オーバーフローしないように先に割る

const ll INF = LLONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("kannondou.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n = 30;
    vector<ll> h(n);
    rep(i,n)
    {
        cin >> h[i];
        if (h[i] == 0) break;
    }

    vector<ll> dp(n);

    for (ll elem : h)
    {
        if (elem == 0) break;
        rep(i,n)
        {
            dp[i] = -INF;
        }
        //cout << elem << endl;

        dp[0] = 1;
        for(int i = 1; i < elem; i++)
        {
            if (i == 1) {dp[i] = 2; continue;};
            if (i == 2) {dp[i] = 4; continue;};
            chmax(dp[i], dp[i-1] + dp[i-2] + dp[i-3]);
        }

        //cout << dp[elem-1] << endl;
        cout << dp[elem-1] / 10 / 365 + 1 << endl;
    }
    return 0;
}

/*
  - 最大値
    - long long : LLONG_MAX, LLONG_MIN, ULLONG_MAX(unsigned long long max)
  - vector
    vector<int> A(N);
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - string
    - loop
      for (char& c : s) {}
 */

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

int num(int n);

int main(){
  int n;
  cin>>n;
  cout << num(n)/3650 + 1<<endl;
}

int num(int n){
    switch (n)
    {
        case 1: return 1;
        case 2:  return 2;
        case 3:  return 4;
    }
  return num(n-1)+num(n-2)+num(n-3);
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=30;

int main(){
    int n;
    ll dp[N+1];

    dp[1]=1;
    dp[2]=2;
    dp[3]=4;

    for(int i=4;i<=N;i++){
        dp[i]= dp[i-1] + dp[i-2] + dp[i-3];
    }

    while(cin>>n,n){
        cout<<ceil(dp[n]/(double)3650)<<endl;
    }

    return 0;
}

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

int dp[31];

int main()
{
	while (true)
	{
		for(int i = 0; i < 31; i++)
			dp[i] = 0;

		int n;
		cin >> n;
		if(n == 0)break;

		dp[1] = 1;
		dp[2] = 2;
		dp[3] = 4;

		for(int i = 4; i <= n; i++)
			dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];

		int ans = 0;
		if(dp[n] / 3650 == 0)ans = 1;
		else
			ans = (dp[n] / 3650) ? dp[n] / 3650 + 1 : dp[n] / 3650;

		cout << ans << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

auto solve(int n) -> long {
  vector<int> dp(n + 1, 1);

  dp[2] = 2;
  for (int i = 3; i <= n; i++) 
    dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
  
  return dp[n];  
}

auto main() -> int {
  int n;
  while(cin >> n, n != 0) {
    auto days = (int)ceil((double)solve(n) / 10);
    auto years = (int)ceil((double)days / 365);
    std::cout << years << std::endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;

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

C++: #include <iostream>
using namespace std;
int main(void){
    int n;
    int dp[31];
    dp[0]=1;
    dp[1]=1;
    dp[2]=2;
    
    for(int i=3; i<=30; i++){
        dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
    }
    while(cin>>n&&n){
        cout<<dp[n]/3650+(dp[n]%3650!=0)<<endl;
    }
    return 0;
}

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

int main()
{
	int s[33] = {1, 1, 2};
	int n;
	
	for (int i = 3; i <= 33; i++){
		s[i] = s[i - 3] + s[i - 2] + s[i - 1];
	}
	
	while (cin >> n, n){
		if (s[n] % 3650 == 0){
			cout << s[n] / 3650 << endl;
		}
		else {
			cout << s[n] / 3650 + 1 << endl;
		}
	}
	
	return (0);
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(n) rep(i,n)
typedef long long ll;
using namespace std;

int n;
ll A[30];
int year[30];

signed main()
{
	A[0] = 1; A[1] = 2; A[2] = 4;
	year[0] = 1; year[1] = 1; year[2] = 1;
	
	for (int i=3; i<30; i++)
	{
		A[i] = A[i-1] + A[i-2] + A[i-3];
		if (A[i] % 3650 > 0) year[i] = A[i] / 3650 + 1;
		else year[i] = A[i] / 3650;
	}
	
	while (cin >> n, n)
	{
		printf("%d\n", year[n-1]);
	}
	
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>

using namespace std;

int main(int argc, char **argv){
	int n;
	vector<int> v;
	int begin[] = { 1, 2, 4 };
	while (cin >> n && n > 0){
		v.clear();
		int count = 0;
		if (n <= 3) {
			count = begin[n - 1];
		} else {
			for (int i = 0; i < 3; i++) {
				v.push_back(begin[i]);
			}

			for (int i = 3; i < n; i++) {
				v.push_back(v[i - 3] + v[i - 2] + v[i - 1]);
			}
			count = v.back();
		}
		
		if (count % 3560 == 0) {
			cout << count / 3650 << endl;
		} else {
			cout << count / 3650 + 1 << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <utility>
#include <queue>
#define INF 1000000007

using namespace std;
typedef long long int ll;

int main(){
    vector<ll> dp(31,0);
    dp[0]=1;
    dp[1]=1;
    dp[2]=2;
    for (int i=3; i<31; i++) {
        dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
    }
    for (;;) {
        int n;
        cin >> n;
        if(n==0) break;
        int ans = dp[n]/(10*365);
        if(dp[n]%365>0) ans++;
        cout << ans <<endl;
    }
}

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

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

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

int main(void){

	int stairs[32],years[32];

	stairs[0]=1;
	stairs[1]=1;
	stairs[2]=stairs[0]+stairs[1];
	years[0]=1;
	years[1]=1;
	years[2]=1;

	int maxi=2;

	int input;
	cin >> input;

	while(input){
		if(input>maxi){
			while(maxi<input){
				maxi++;
				stairs[maxi]=stairs[maxi-1]+stairs[maxi-2]+stairs[maxi-3];
				years[maxi]=stairs[maxi]/3650;
				if(stairs[maxi]%3650)
					years[maxi]++;
			}
			cout << years[input] << endl;
		}else{
			cout << years[input] <<endl;
		}
		cin >> input;
	}

	return 0;

}