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 <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	ll dp[35]={0};
	dp[1]=1ll,dp[2]=2ll,dp[3]=4ll;
	for(int i=4;i<33;i++)
	{
		dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
	}
	int n;
	while(1)
	{
		cin >> n;
		if(n==0)break;
		ll day=dp[n]/10+(dp[n]%10!=0);
		ll year=day/365+(day%365!=0);
		cout << year << endl;
	}
	return 0;
}

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))

#define MOD(x, y) ((x) % (y))
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))
#define DIVFLOOR(x, y) (((x) + ((y) / 2)) / (y))
#define DIVROUND(x, y) ((x) - MOD(x, y) >= MOD(x, y) ? DIVCEIL(x, y) : DIVFLOOR(x, y))

constexpr int MAX_N = 30;
constexpr int MAX_K = 3;

int dp[MAX_N+1];

int main() {
  int N;
  while (true) {
    cin >> N;
    if (N == 0)
      break;
    fill_n(dp, MAX_N+1, 0);
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;

    for (int i{MAX_K}; i <= N; ++i) {
      for (int j{1}; j <= MAX_K; ++j) {
        dp[i] += dp[i-j];
      }
    }

    cout << DIVCEIL(dp[N], 3650) << endl;
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long long int dp[30][3] = {};
  dp[1][1] = 1;
  dp[2][1] = dp[2][2] = 1;
  dp[3][1] = 2;
  dp[3][2] = dp[3][3] = 1;
  for(int i=4;i<31;++i)
    for(int j=1;j<4;++j)
      dp[i][j] += dp[i-j][1] + dp[i-j][2] + dp[i-j][3];
  
  while(cin>>n, n){
    long long int ans=0;
    for(int i=1;i<4;++i)
      ans += dp[n][i];
    ans = (ans+9)/10;
    ans = (ans+364)/365;
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
 
int num(int n);
 
int main(){
  int n;
  cin>>n;
  cout << (num(n)+3649)/3650<<endl;
}
 
int num(int n){
    switch (n)
    {
        case -1: return 0;
        case 0:  return 0;
        case 1:  return 1;
    }
  return num(n-1)+num(n-2)+num(n-3);
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int dp[41];


int main(){
    memset(dp,0,sizeof(dp));
    dp[0] = 1;
    for(int j=0;j<30;j++){
	for(int i=1;i<=3;i++){
	    dp[i+j] += dp[j];
	}
    }
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	int fact = dp[n]/10 + ((dp[n]%365==0) ? 0 : 1) ;
	cout << fact/365 + ((fact%365==0) ? 0 : 1) << endl;
    }
    return 0;
}

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

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

C++: #define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168"

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

#define call_from_test
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename R>
struct Kitamasa{
  using VR = vector<R>;
  VR cs;
  vector<VR> rs;
  int m;

  Kitamasa(const VR &C)
    :cs(C),rs(1),m(C.size()){
    rs[0].assign(2*m+1,R::add_identity());
    rs[0][1]=R::mul_identity();
  }

  VR merge(const VR &xs,const VR &ys){
    VR zs(2*m+1,R::add_identity());
    for(int i=1;i<=m;i++)
      for(int j=1;j<=m;j++)
        zs[i+j]=zs[i+j]+(xs[i]*ys[j]);

    for(int i=2*m;i>m;zs[i--]=R::add_identity())
      for(int j=1;j<=m;j++)
        zs[i-j]=zs[i-j]+(cs[m-j]*zs[i]);
    return zs;
  }

  R calc(const VR &A,long long n){
    assert((int)A.size()==m);
    VR res(rs[0]);
    for(int i=0;n;i++,n>>=1){
      if(i>=(int)rs.size())
        rs.emplace_back(merge(rs[i-1],rs[i-1]));
      if(~n&1) continue;
      res=merge(res,rs[i]);
    }
    R ans=R::add_identity();
    for(int i=1;i<=m;i++) ans=ans+(res[i]*A[i-1]);
    return ans;
  }
};
//END CUT HERE
#ifndef call_from_test

#define call_from_test
#include "../mod/mint.cpp"
#undef call_from_test

//INSERT ABOVE HERE
signed TDPC_F(){
  using ll = long long;
  int n;
  ll k;
  scanf("%d %lld",&n,&k);

  using M = Mint<int>;
  vector<M> as(n,1),cs(n,1);
  Kitamasa<M> fib(cs);

  printf("%d\n",fib.calc(as,--k).v);
  return 0;
}
/*
  verified on 2019/12/10
  https://atcoder.jp/contests/tdpc/tasks/tdpc_fibonacci
*/

signed ABC009_D(){
  int k,m;
  scanf("%d %d",&k,&m);

  struct M{
    uint32_t v;
    M(){*this=add_identity();}
    M(uint32_t v):v(v){}
    M operator+(const M &a)const{return M(v^a.v);}
    M operator*(const M &a)const{return M(v&a.v);}
    static M add_identity(){return M(0);}
    static M mul_identity(){return M(~0u);}
  };

  vector<M> as(k),cs(k);
  for(int i=0;i<k;i++) scanf("%u",&as[i].v);
  for(int i=0;i<k;i++) scanf("%u",&cs[k-(i+1)].v);
  Kitamasa<M> v(cs);

  printf("%u\n",v.calc(as,--m).v);
  return 0;
}
/*
  verified on 2019/12/10
  https://atcoder.jp/contests/abc009/tasks/abc009_4
*/

signed main(){
  //TDPC_F();
  //ABC009_D();
  return 0;
}
#endif

#undef call_from_test

template<typename T>
struct Z{
  T v;
  Z(){*this=add_identity();}
  Z(T v):v(v){}
  Z operator+(const Z &a)const{return Z(v+a.v);}
  Z operator*(const Z &a)const{return Z(v*a.v);}
  static Z add_identity(){return Z(0);}
  static Z mul_identity(){return Z(1);}
};

signed main(){
  using ZL = Z<long long>;

  vector<ZL> as({0,0,1}),cs({1,1,1});
  Kitamasa<ZL> K(cs);

  int n;
  while(cin>>n,n)
    cout<<(K.calc(as,n+2).v+3650-1)/3650<<endl;

  return 0;
}

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

int n = 0;

int dfs(int step) {
	if (step == n) return 1;
	if (step > n) return 0;
	return dfs(step+1) + dfs(step+2) + dfs(step+3);
}

int GetYears(int c) {
	int days = c / 10;
	if (c % 10 != 0) days++;
	int years = days / 365;
	if (days % 365 != 0) years++;
	return years;
}

int main() {
	for(;;) {
		cin >> n;
		if (n == 0) break;
		cout << GetYears(dfs(0)) << endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;
int A[128],N;
int main() {
  while(cin>>N && N>0) {
  A[0] = 1;
    for (int i=1; i<=N; ++i) {
      A[i] = A[i-1];
      if(i>=2) A[i] += A[i-2];
      if(i>=3) A[i] += A[i-3];
    }
    cout << ceil(A[N]/3650.0) << endl;
  }
}