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 <stdio.h>
const int N=31;
int main(){
    int n,dp[N];
    dp[0]=1;
    dp[1]=1;
    dp[2]=2;
    for(int i=3;i<N;i++)dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
    while(true){
        scanf("%d",&n);
        if(n==0)return 0;
        printf("%d\n",(dp[n]+3649)/3650);
    }
}

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

int main() {
  int n;
  long long int dp[31];
  
  while(cin>>n, n) {
    fill(dp, dp+31, 0);
    dp[0]=dp[1]=1; dp[2]=2; dp[3]=4;
    if(n==1) { cout << 1 << endl; continue; }
    else if(n==2) { cout << 2 << endl; continue; }
    else {
      for(int i=4; i<=30; i++) {
	dp[i]=dp[i-3]+dp[i-2]+dp[i-1];
      }
    }

    cout << dp[n]/3650+1 << endl;
  }

  return 0;
}

C++: #include <iostream>

#define MAX_N 30
#define INF -1

int memo[MAX_N], ans, n;

void solve();

int dp(int a);

int answer(int in);

int main(){
    while(true){
        std::cin >> n;
        
        if(n == 0)
            break;
        
        for(int i = 0; i < MAX_N; ++i)
            memo[i] = INF;
        
        solve();
        
        std::cout << answer(ans) << std::endl;
    }
    return 0;
}

void solve(){
    ans = dp(n + 1);
    return;
}

int dp(int a){
    if(a < 1) return 0;
    if(a == 1) return 1;
    
    if(memo[a] == INF){
        memo[a] = dp(a - 1) + dp(a - 2) + dp(a - 3);
        return memo[a];
    }
    
    return memo[a];	
}

int answer(int in){
    return (in / 10) / 365 + 1;
}

C++: #include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int calcYear(int date){
    if(date % 10 == 0) date /= 10;
    else date = (date / 10) + 1;

    if(date % 365 == 0) return date / 365;
    else return (date / 365) + 1;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int dp[40];
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;
    for(int i=3;i<31;i++){
        dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
    }
    int n;
    vector<int> ans;
    while(1){
        cin >> n;
        if(n == 0) break;
        ans.push_back(dp[n] / 3650 + 1);
    }
    for(int i=0;i<ans.size();i++) cout << ans[i] << endl;
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <list>
#include <functional>
#include <algorithm>

using namespace std;

unsigned long long ns[35];

int main(int, char**){
    ns[0] = 1;
    ns[1] = 2;
    ns[2] = 4;
    for(int i(3);i<31;++i)
	ns[i]=ns[i-1]+ns[i-2]+ns[i-3];
    int n;
    while(cin >> n){
	if (n ==0) break;
	int tmp = ns[n-1] / (365*10) + (ns[n-1] % 3650 != 0);
	cout << tmp <<endl;
    }
    return 0;
}

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

int main() {
  int n;
  int step[31] = {1,1,2};
  for(int i=3;i<31;i++) {
    step[i] = step[i-1]+step[i-2]+step[i-3];
  }
  while(cin >> n) {
    if(n==0) break;
    cout << (step[n]+3650)/3650 << endl;
  }
}

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

int main(){
	int n;
	double ans =0;
	int checkc = 0;
	int i = 4;
	double check[3] = { 1, 2, 4 };

	cin >> n;

	switch (n){
	case 1:
		ans = 1;
		break;
	case 2:
		ans = 2;
		break;
	case 3:
		ans = 4;
		break;
	default :
		while (n >= i){
			ans = check[0] + check[1] + check[2];
			i++;
			check[0] = check[1];
			check[1] = check[2];
			check[2] = ans;
		}
	}

	ans = ans / 3650;
	checkc = (int)(ans);

	if (ans > (double)(checkc)){
		checkc++;
	}
	if (ans != 0){
		cout << checkc << endl;
	}

	return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T, typename U>
void print1(T Array, U size) {
  for (int i = 0; i < size; i++) {
    cout << Array[i] << " ";
  }
  cout << endl;
}

template<typename T>
void print(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

// ------------------------------------------------------------------------------------------

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

  return 0;
}

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); }


int main()
{
	for(int n; cin >> n && n;)
	{		
		int dp[32] = {0};
		
		dp[0] = 1;
		rep(i, n) rep(j, 3) if(i + j + 1 <= n) dp[i + j + 1] += dp[i];
		
		cout << ((dp[n] + 9) / 10 + 364) / 365 << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;
//けんちょんさんの記事を参考に

//ＤＰ　テーブル
long long dp[100010]={0};

int main(){

    for ( int i = 0 ; i < 30 ; i++){
    int n; cin >> n;
    if ( n == 0 ) return 0;

    //初期化・初期条件
    dp[10010] = {};
    dp[0] = 1;

    //ループ
    for ( int j = 0 ; j <= n ; j++ ){
        if ( j==1 ) dp[j] = dp[j-1];
        if ( j==2 ) dp[j] = dp[j-1] + dp[j-2];
        if ( j>2 ) dp[j] = dp[j-1] + dp[j-2] + dp[j-3];
    }
    cout << ( ( dp[n] - 1) / (365*10) ) + 1 << endl;
    }
}