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 _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < ((k)+(n)); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 
template <class _Tv> inline string join(const _Tv &v,string sep=" "){
    ostringstream s;FOREACH(it,v){if(it!=v.begin())s<<sep;s<<*it;};return s.str();
}

typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef complex<D> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define X real()
#define Y imag()
#define EPS (1e-9)
#define DEQ(p1,p2) (abs((p1)-(p2)) < EPS)

#ifdef _DEBUG
template<class _Tv> inline void _prfe(const char *_n,const _Tv _c,bool _p=false){
    ITER(_c) _it=_c.begin();
    if(_p){cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{cout<<_n<<" = [ "<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;cout<<" ]"<<endl; }
}
ostream &operator<<(ostream &os, const pair<int,int> &p){return(os<<"("<<p.first<<","<<p.second<<")");}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif

int main(){
    ll dp[31];
    FILL(dp,0);
    dp[0] = 1;
    REP(i,31){
        REP(j,3) dp[i+j+1] += dp[i];
    }

    int n;
    while(cin >> n && n){
        cout << (dp[n]+3649)/3650 << endl;
    }
    return 0;
}

C++: int main()
{
	int n,i;
	int ans[64]={0};
	
	ans[0]=ans[1]=1;
	ans[2]=2;
	
	for(i=3;i<31;i++)
		ans[i]=ans[i-1]+ans[i-2]+ans[i-3];
	
	for(;;)
	{
		cin >> n ;
		if(n==0)
			break;
		printf("%d\n",ans[n]/3650+1);
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int dfs( int );
long long int memo[31]={};
int main(){
  int n ,ans;
  while( true ){
    cin >> n;
    if( n == 0 ) break;
    ans = dfs( n );
    
    ans /= 3650;
    cout << ans+1 << endl;
  }
}

int dfs( int n ){
  if( memo[n] ) return memo[n];
  if( n <= 1 ) return 1;
  if( n == 2 ) return 2;
  return memo[n] = dfs( n-1 ) + dfs( n-2 ) + dfs( n-3 );
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
#define f(i, k, j) for(int i = k; i < j; i++)
#define P pair<int, int>
const int INF = (1 << 26);
const int MAX_N = 31;
long long int dp[MAX_N];

void solve(){
    memset(dp, 0, sizeof(dp));
    dp[1] = 1; dp[2] = 2; dp[3] = 4;
    for(int i = 4; i < MAX_N; i++){
        dp[i] = dp[i - 3] + dp[i - 2] + dp[i - 1];
    }
}

int main(){
    solve();
    int n;
    while(cin >>n && n != 0){
        int ans = dp[n] / 3650;
        if(dp[n] % 3650 != 0) ans++;
        cout <<ans <<endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int Kannondou(int n){
	int dp[4] = {1,2,4,0};

	if(n<=3)
		return dp[n-1];

	for(int i = 3; i < n; ++i){
		dp[ 3 ] = dp[ 2 ] + dp[ 1 ] + dp[ 0 ];
		dp[ 0 ] = dp[ 1 ];
		dp[ 1 ] = dp[ 2 ];
		dp[ 2 ] = dp[ 3 ];
	}
	return dp[ 3 ] / 3650 + 1;
}
int main(){
	while(true){
		int n;

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

		cout << Kannondou( n ) << endl;
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 32;

long long d[MAXN], day, year;

int main()
{
    d[0] = 1;
    d[1] = 1;
    d[2] = 2;
    REP(MAXN-3) d[i+3] = d[i]+d[i+1]+d[i+2];
    
    int n;
    while(cin >> n && n)
    {
        day = d[n] / 10;
        if(d[n] % 10  > 0 ) day++;
        year = day/365;
        if(day % 365 > 0) year++;

        cout << year << endl;
    }
    return 0;
}

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

ll dp[31];
ll memo[31];

ll rec(ll n){
    if(n < 0) return 0;
    if(n < 2) return 1;
    if(memo[n]) return memo[n];
    
    return memo[n] = rec(n - 1) + rec(n - 2) + rec(n - 3);

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    while(true){
        ll n;
        cin >> n;
        
        if(n == 0) return 0;
        
        rep(i,31){
            memo[i] = 0;
        }
        
        cout << rec(n)/3650 + 1<< endl;
    }
}

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

int s[30];
int n;

int main() {
  
  while(1) {
    cin >> n;
    if(!n)break;
    
    s[0] = 1;
    s[1] = 2;
    s[2] = 4;
    
    for(int i=3;i<n;i++) {
      s[i] = s[i-1]+s[i-2]+s[i-3];
    }
    int r = s[n-1]/10;
    r += s[n-1]%10?1:0;
    r = (r-1)/365 + 1;
    cout << r << endl;
    
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int main() {
  int a, kai[31];
  kai[0] = 1;
  kai[1] = 1;
  kai[2] = 2;
  for (int i = 3; i < 31; i++) {
    kai[i] = kai[i - 1] + kai[i - 2] + kai[i - 3];
  }
  rep(i, 31) kai[i] = (kai[i] + 3649) / 3650;
  while (cin >> a, a)
    cout << kai[a] << endl;
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;
#define le 1000000007;
int main(void){
  while(1==1){
  int n;
  cin >> n;
  if(n==0)return 0;
  int k[128];
  int memo[128];
  vector<int> fla(128,0);
  k[0]=0;
  k[1]=1;
  k[2]=2;
  k[3]=4;
  if(n==1 || n==2 || n==3){
    cout << 1 << endl;return 0;
  }
  if(fla[n]==8){
    cout << memo[n]/3650+1 << endl;
    return 0;
  }
  for(int i=4;i<=n;i++){
    k[i]=k[i-1]+k[i-2]+k[i-3];
    memo[i]=k[i];
    fla[i]=8;
  }
  cout << k[n]/3650+1 << endl;
}
  return 0;
}