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 main(void){
    int n,a[31],year,i;
    a[1] = 1;
    a[2] = 2;
    a[3] = 4;
    for(i = 4; i < 31; i++){
        a[i] = a[i-3] + a[i-2] + a[i-1]; 
        //cout << n[i] << endl;                   //a[i]=何通りか
    }
    while(true){
        cin >> n;                                   //n=段数   
        if(n == 0)    break;
        else{
            year = a[n] / 3650;
            cout << year + 1 << endl; 
        }
    }
}

C++: #include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n; //nは階段の段数
    int sum[31]; //上り方の種類数
    
    while(true){
        cin >> n;
        if(n == 0) break;
        
        for(int i = 1; i < 31; i++){
            if(i == 1) sum[i] = 1;
            else if(i == 2) sum[i] = 2;
            else if(i == 3) sum[i] = 4;
            else sum[i] = sum[i - 1] + sum[i - 2] + sum[i - 3];
        }
        
        int day, year;
        for(int i = 1; i < 31; i++){
            if(sum[i] % 10 != 0) day = sum[i] / 10 + 1;
            else day = sum[i] / 10;

            if(i == n){
            if(day > 365) year = day / 365 + 1;
            else year = 1;
            }
        }  
        cout << year << endl;
        // if(day > 365) cout << day / 365 + 1 << endl;
        // else cout << "1" << endl;
    }
}

C++: #include <iostream>
#include<vector>
using namespace std;
vector<int>  memo;
int f(int n){
    if(n<0)
        return 0;
    if(n==0)
        return 1;
    if ( memo[n]!= -1 )
        return memo[n];
    return f(n-1)+f(n-2)+f(n-3);
}
 
int main(){
    int n;
    memo.resize(31,-1);
    while(1){
        cin >> n;
        if(n==0)
            break;
        int num=f(n);
        cout <<num/10/365+1<< endl;
    }
    return 0;  
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T, typename U>
void print1(T Array, U size) {
  for (int i = 0; i < size; i++) {
    cout << Array[i] << " ";
  }
  cout << endl;
}

template<typename T>
void print(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

// ------------------------------------------------------------------------------------------

int n;

int rec(int stage) {
  if (stage == 0) {
    return 1;
  }

  int ans = 0;

  for (int i = 1; i <= 3; i++) {
    if (stage - i < 0) continue;
    ans += rec(stage - i);
  }

  return ans;
}

signed main() {
  while (1) {
    cin >> n;
    if (n == 0) break;
    int t = (rec(n) + 3650 - 1) / 3650;
    cout << t << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int R = 1e9 + 7; 

int main() {
    while (1) {
        int n; cin >> n;
        if (n == 0) break;
        ll dp[n + 1];
        dp[0] = 1, dp[1] = 2, dp[2] = 4;
        for (int i = 3; i < n; i++) {
            dp[i] = dp[i - 3] + dp[i - 2] + dp[i - 1];
        } 
        ll ans = (364 + ((dp[n - 1] + 9) / 10)) / 365;
        cout << ans << endl;
    }
    return 0;
}

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

int A[128], n, a; 
int main() {
	while(cin >> n && n >0){
		A[0] = 0;
		A[1] = 1;
		A[2] = 2;
		for (int i=3; i<=n+10; ++i) {
			A[i] = A[i-1]+A[i-2]+A[i-3];
		}
		a = int((A[n]+9)/10);
		a = int(a+364)/365);
	cout << a <<endl;
	}
}

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

int solve(int n);
int dp[100];

int main(){
	int n;
	while(cin >> n , n){
		memset(dp,0,n+2);
		int ans = solve(n);
		cout << ans/365/10+1 << endl;
	}
}

int solve(int n){
	if(n == 0) return 1;
	if(dp[n] != 0) return dp[n];
	int cou=0;
	for(int i=1;i<=3;i++){
		if(n-i >= 0) cou += solve(n-i);
	}
	return dp[n] = cou;
}

C++: #include<iostream>

using namespace std;

int main(){

	int n;

	while(n>0){

		cin >> n;

		int set = n / 3;
		int r = n % 3;
		int total = 0;

		while(set > 0){
			if(set == n / 3){total += 4;}
			else{
				total = total * 4 * 2 - 8;
			}
			set--;
		}

		if(n < 3){
			total += r;
		}
		else{
			if(r == 1){
				total = total * 2 - 1;
			}
			else if(r == 2){
				total = total * 4 - 3;
			}
		}

		int ans = total / 3650;

		if(total % 3650 != 0){
			ans++;
		}

		cout << ans << endl;

	}

	return 0;
}

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

const int MOD = 1000000007;
template<class T> inline void add_mod(T &a, const T b) {
	a += b;
	if(a >= MOD) a -= MOD;
}

long dp[35];

int main(){
	int n;

	dp[0] = 1;
	for(int i = 1; i <= 30; i++) {
		if(i - 1 >= 0) add_mod(dp[i], dp[i-1]);
		if(i - 2 >= 0) add_mod(dp[i], dp[i-2]);
		if(i - 3 >= 0) add_mod(dp[i], dp[i-3]);
	}

	while(true) {
		scanf("%d", &n);
		if(n == 0) break;
		printf("%ld\n", dp[n] / 3650 + 1);
	}
}

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

int main() {
  int n;
  long long int dp[31];
  
  while(cin>>n, n) {
    fill(dp, dp+31, 0);
    dp[0]=dp[1]=1; dp[2]=2;
    if(n==1) { cout << 1 << endl; continue; }
    else if(n==2) { cout << 2 << endl; continue; }
    else {
      for(int i=3; i<30; i++) {
	dp[i]=dp[i-3]+dp[i-2]+dp[i-1];
      }
    }

    cout << dp[n]/3650+1 << endl;
  }

  return 0;
}

C++: #include <iostream>

using namespace std;

int dp[32];
void DPCalc()
{
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	for(int i = 0; i < 28; ++i)
	{
		dp[i + 3] = dp[i] + dp[i + 1] + dp[i + 2];
	}
}

void solve()
{
	DPCalc();
	int n;
	while(cin >> n)
	{
		if(n == 0)
		{
			break;
		}
		int ans = dp[n] / 365 / 10 + 1;
		cout << ans << endl;
	}
}

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