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>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;
ll memo[100];

ll solve(int now) {
	if (now == 0)return 1;
	if (now < 0)return 0;
	if (memo[now] != -1)return memo[now];
	return memo[now] = solve(now - 1) + solve(now - 2) + solve(now - 3);
}

int main() {
	fill(memo, memo + 100, -1);
	solve(30);
	while (cin >> n&&n) {
		cout << memo[n] / 3650 + 1 << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
    int v[50];
    v[0]=1;
    v[1]=v[0];
    v[2]=v[1]+v[0];
    for(int i=3;i<=30;i++){
        v[i]=v[i-1]+v[i-2]+v[i-3];
    }
    int n;
    while(1){
        cin>>n;
        if(n==0)break;
        cout<<((v[n]+9)/10+364)/365<<endl;
    }
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    int dp[35];
    rep(i,35) dp[i] = 0;
    dp[0] = 1;
    rep(i,35){
        dp[i+1] += dp[i];
        dp[i+2] += dp[i];
        dp[i+3] += dp[i];
    }
    int n;
    while(cin >> n && n) {
        int step = dp[n];
        int ans = step/3650;
        if(step%3650 != 0) ans++;
        cout << ans << endl;
    }
}

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

int main() {

    while(1){
        int n;
        cin >> n;
        if (!n) return 0;
        vector<long long> dp(n + 1);
        dp[0] = 1;
        dp[1] = 1;
        dp[2] = 2;
        for (int i = 1; i <= n; ++i) {
            dp[i] = dp[i - 1] + (i > 1 ? dp[i - 2] : 0) + (i > 2 ? dp[i - 3] : 0);
        }
        cout << (dp[n] + 3650 - 1) / 3650 << "\n";
    }
}

C++: #include <algorithm>
#include <iostream>
#include <string>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;

int main() {
    while(1) {
        int n;
        cin >> n;
        if(n==0) {
            break;
        }
        int dp[30];
        dp[0] = 1;
        dp[1] = 2;
        dp[2] = 4;
        FOR(i,3,n) {
            dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
        }
        if(dp[n] % 3650 == 0) { 
            cout << dp[n-1] /3650 << endl;
        } else {
            cout << dp[n-1] /3650 + 1 << endl;
        }
         
    }
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX_N 30
int dp[MAX_N + 1];
bool checked[MAX_N + 1];
//??\???

int count(int n) {
  if ( n == 1 ) return 1;
  if ( n == 2 ) return 2;
  if ( n == 3 ) return 4;

  if(checked[n] == true){
    return dp[n];
  } else {
    int res = count(n-1) + count(n-2) + count(n-3);
    dp[n] = res;
    return res;
  }

}

int main() {
  ios::sync_with_stdio(false);

  int n, years;
  while(cin >> n) {
    if (n==0) break;
    int c = count(n);
    years = ( c / 3650 ) + (c % 3650 == 0 ? 0 : 1);
    cout << years << endl;
  }

  return 0;
}

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

// ceil() for integer dividing
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))

constexpr int MAX_N = 30 + 1;
int N;
int dp[MAX_N];

int main() {
  while (true) {
    cin >> N;
    if (N == 0)
      break;
    dp[0] = 0;
    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];
    }
    cout << DIVCEIL(dp[N], 365 * 10) << endl;
  }

  return 0;
}

C++: #include<iostream>

using namespace std;

int main(){

	int n;

	int memo[100];

	while(1){

		cin>>n;

		if(n==0) break;

		memo[0]=1;
		memo[1]=1;
		memo[2]=2;
		for(int i=3;i<=n;i++){
			memo[i]=memo[i-1]+memo[i-2]+memo[i-3];
		}
		cout<<memo[n]<<endl;
	}
}

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

int dan;
long long int memo[40];

int main(){
  memo[1]=1;
  memo[2]=2;
  memo[3]=4;
  for(int i=4;i<31;i++){
    memo[i]=memo[i-1]+memo[i-2]+memo[i-3];
  }
  
  while(1){
    cin>>dan;
    if(dan==0){break;}
    cout<<memo[dan]<<endl;
    }
}

C++: 
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;

int A[128], n; 
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];
		}
		double a = floor((A[n]+9)/10);
		double b = floor((a+364)/365);
	cout << b <<endl;
	}
}

C++: #include<iostream>
using namespace std;
int kan(int i)
{
if(i==0)
{
  return 1;
}
else if(i==1)
{
  return kan(i-1);
}
else if(i==2)
{
  return kan(i-1)+kan(i-2);
}
else
{
  return kan(i-1)+kan(i-2)+kan(i-3);
}
};
int main()
{
 int i,days,years;
 while(cin>>i&&i)
 {
  if(kan(i)%10!=0)
    days=(kan(i)/10)+1;
  else
    days=kan(i)/10;

  if(days%365!=0)
    years=(days/365)+1;
  else
    years=days/365;
  cout<<years<<endl;
 }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

vector<LL> memo;

LL solve(int n) {
	if (n < 0) return 0;
	if (memo[n] != -1) return memo[n];
	if (n == 0) return memo[n] = 1;

	return memo[n] = solve(n - 1) + solve(n - 2) + solve(n - 3);
}

int main(void) {
	memo.resize(31, -1);
	int N;
	
	while (cin >> N, N) {
		cout << ((solve(N) + 9) / 10 + 364) / 365 << endl;
	}

	return 0;
}