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 <vector>

using namespace std;

typedef long long ll;

ll solve(int n) {
    vector<ll> step(n);
    step[0] = 1;
    if( n > 1 ) step[1] = 2;
    if( n > 2 )  step[2] = 4;
    for(int i=3; i < n; ++i){
        step[i] = step[i-3] + step[i-2] + step[i-1];
    }
    return step[n-1];
}

ll getdays(ll ptns){
    if(ptns % 10 == 0) return ptns / 10;
    else return ptns / 10 + 1;
}

ll getyears(ll days){
    if(days % 365 == 0) return days / 365;
    else return days / 365 + 1;
}

int main(){
    int n;
    while((cin >> n) != 0) {
        cout << getyears(getdays(solve(n))) << endl;
    }
}

C++: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
ll dp[31];
void mainmain(){
	dp[1]=1;
	dp[2]=2;
	dp[3]=4;
	reep(i,4,31){
		rep(j,3){
			dp[i]+=dp[i-j-1];
		}
	}
	// reep(i,4,7){
		// cout<<dp[i]<<endl;
	// }
	// rep(i,35){
		// cout<<i<<" "<<i*3650<<endl;
	// }
	int n;
	while(cin>>n){
		ll t=dp[n]-1;
		// cout<<t<<endl;
		t/=3650;
		cout<<t+1<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

C++: #include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	unsigned long long dp[100];
	dp[0] = 0;
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;
	rep(i,4,40){
		dp[i] = dp[i-1] + dp[i-2] + dp[i-3];	
		//cout << i << ":"  << dp[i] << endl;
	}
	
	rep(i,0,40){
		if(dp[i] % 10 )
			dp[i] = dp[i] / 10 + 1;
		else
			dp[i] = dp[i] / 10;
	}
	
	rep(i,0,40){
		//cout << i << ":" << dp[i] << endl;
	}

	int n;
	while( cin >> n ){
		if( dp[n] % 365 )
			cout << dp[n] / 365 + 1 << endl;
		else
			cout << dp[n] / 365 << endl;
	}

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

int main() {
  int n;
  long long dp[50] = {0};
  for (int i = 0; i <= 30; i++) {
    if (i == 0) {
      dp[i] = 1;
    }
    else if (i == 1) {
      dp[i] = dp[i-1];
    }
    else if (i == 2) {
      dp[i] = dp[i-2] + dp[i-1];
    }
    else {
      dp[i] = dp[i-3] + dp[i-2] + dp[i-1];
    }
  }
  while (cin >> n && n > 0) {
    cout << (dp[n] + 3650 - 1)/3650 << endl;
  }
  return 0;
}

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

using namespace std;

struct Memo
{

  int count;
  bool flag;

  Memo()
  {
    count = 0;
    flag = false;
  }

};

Memo memo[31][4];

int ProgressNumberOfYears(int step_num, int step_kind)
{

  int kind_count = 0;


  if(step_num == 0) return 1;
  else if(step_num < 0)  return 0;
  else if(memo[step_num][step_kind].flag)  return memo[step_num][step_kind].count;
  for(int i = 1; i < 4; ++i) kind_count = kind_count + ProgressNumberOfYears(step_num - i,i);


  memo[step_num][step_kind].count = kind_count;
  memo[step_num][step_kind].flag = true;

  return kind_count;

}

int main()
{

  int step_num;

  while(cin >> step_num && step_num != 0) cout << ProgressNumberOfYears(step_num,0)/10/365 + 1<< endl;

  return 0;

}

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;
		for (int i = 0; i <= n; ++i)
			dp[i] = 0;

		for (int i = 1; i <= 3; ++i){
			for (int j = 1; j <= n; ++j){
				if (j >= i){
					dp[j] = std::max(dp[j], dp[j - i] + 1);
				}
			}
		}
		int ans = (dp[n] % 365 == 0) ? dp[n] / 365 : dp[n] / 365 + 1;
		printf("%d",ans);
	}
	return 0;
}

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

using namespace std;

int main(){

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

	int n;
	while(cin>>n&&n!=0){
		int t = (dp[n]-1)/3650;
		t++;
		cout<<t<<endl;
	}

	return 0;
}

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

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

int main() {
    while(1) {
        int n;
        cin >> n;
        if(n == 0) break;

        vector<float> step(3);
        step[0] = 1;
        step[1] = 2;
        step[2] = 4;

        for(int i = 3; i < n; i++) {
        int count = step[i-3] + step[i-2] + step[i-1];   
        step.push_back(count);
        }

        cout << ceil(step[n-1]/10/365) << endl;
        step.clear();
    }

return 0;
}

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

#define int long long

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 ans = (rec(n) + 3650 - 1) / 3650;
    cout << ans << endl;
  }

  return 0;
}