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(){
	int n;
	int m[31] = {1, 1, 2};

	for(int i= 3; i <= 30; i++){
		m[i] = m[i-1] + m[i-2] + m[i-3];
	}
	while(cin >> n, n){
		cout << m[n] / (365 * 10) + 1 << endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

ll memo[32];
ll rec(int n, int p)
{
	if(n < p) return 1;
	if(0 <= memo[p]) return memo[p];
	
	return memo[p] = rec(n, p + 1) + rec(n, p + 2) + rec(n, p + 3);
}

int main()
{
	for(int n; cin >> n && n;)
	{
		vector<vint> dp(n + 2, vint(n + 1));
		
		dp[0][0] = 1;
		rep(i, n + 1) rep(j, n)
		{
			dp[min(n + 1, i + 1)][j + 1] += dp[i][j];
			dp[min(n + 1, i + 2)][j + 1] += dp[i][j];
			dp[min(n + 1, i + 3)][j + 1] += dp[i][j];
		}
		
		cout << (accumulate(ALL(dp[n]), 0) + 3649) / 3650 << endl;
	}
}

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;
        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 <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repn(i,n,m) for(int i=n;i<m;i++)
#define repn1(i,n,m) for(int i=n;i<=m;i++)
using namespace std;

int main(){

	int dp[30] = {0};
	int n;
	
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;

	repn(i, 4, 30) dp[i] = dp[i-1] + dp[i-2] + dp[i-3];

	while(cin >> n, n){

		cout << dp[n] / 3650 + (dp[n]%3650==0 ? 0 : 1) << endl;
	}

	return 0;
}

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

int num(int n);

int main(){
  int n;
  cout << num(cin>>n) <<endl;
}

int num(int n){
  if(n<0)return 0;
  return num(n-1)+num(n-2)+num(n-3);
}

C++: #include<bits/stdc++.h>

using namespace std;

struct Matrix
{
  vector< vector< long long > > a;

  Matrix(int N)
  {
    a.resize(N, vector< long long >(N));
  }

  Matrix operator+(const Matrix &kj)
  {
    Matrix ret(a.size());
    for(int i = 0; i < a.size(); i++) {
      for(int j = 0; j < a.size(); j++) {
        ret.a[i][j] = a[i][j] + kj.a[i][j];
      }
    }
    return (ret);
  }

  Matrix operator*(const Matrix &kj)
  {
    Matrix ret = Matrix::Zero(a.size());
    for(int i = 0; i < a.size(); i++) {
      for(int j = 0; j < a.size(); j++) {
        for(int k = 0; k < a.size(); k++) {
          ret.a[i][j] = (ret.a[i][j] + 1LL * a[i][k] * kj.a[k][j]);
        }
      }
    }
    return (ret);
  }

  Matrix operator^(long long n)
  {
    Matrix ret = Matrix::I(a.size());
    Matrix x = *this;
    while(n > 0) {
      if(n & 1) (ret = ret * x);
      x = x * x;
      n >>= 1;
    }
    return (ret);
  }

  static Matrix Zero(int N)
  {
    Matrix ret(N);
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) ret.a[i][j] = 0;
    }
    return (ret);
  }

  static Matrix I(int N)
  {
    Matrix ret(N);
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) ret.a[i][j] = i == j;
    }
    return (ret);
  }
};

int main()
{
  int n;
  while(cin >> n, n) {
    Matrix tt(3);
    tt.a = {{1, 1, 1},
            {1, 0, 0},
            {0, 1, 0}};
    tt = tt ^ n;
    cout << (tt.a[2][0] * 2 + tt.a[2][1] + tt.a[2][2] + 3649) / 3650 << endl;
  }
}

C++: #include <bits/stdc++.h>

using namespace std;

//aとbを比較して、aに小さいほうを入れる。bのほうが小さければtrueを戻す
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;}return false;}

//aとbを比較して、aに大きいほうを入れる。bのほうが大きければtrueを戻す
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;}return false;}

int main(void){
  while(true){
  int n; cin >> n;
  if(n == 0)break;
  vector<long long> dp(n+1, 0);
  dp[0] = 1;
  for(int now = 0; now < n; now++){
    for(int next = now+1; next <= min(n, now+3); next++){
      dp[next] += dp[now];
    }
  }
  cout << ceil((double)dp[n] / 10 / 365) << endl; 
  }
  return 0;
}

C++: #include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(itr,data) for(__typeof((data).begin()) itr=(data).begin();itr!=(data).end();++itr)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;

int solve(int n) {
    long long dp[40];
    rep(i,40) dp[i]=0;
    dp[0]=1;

    rep(i,n+1) {
        dp[i+1] += dp[i];
        dp[i+2] += dp[i];
        dp[i+3] += dp[i];
    }

    return dp[n]/10/365 + 1;

}

int main()
{
    int n;
    while(true) {
        cin>>n;
        if(!n) return 0;
        cout<<solve(n)<<endl;
    }
    return 0;
}