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 <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

VI memo;

int solve( int n )
{
	if ( n == 0 )
	{
		return 1;
	}
	else if ( n < 0 )
	{
		return 0;
	}

	if ( memo[n] != -1 )
	{
		return memo[n];
	}

	return memo[n] = solve( n - 1 ) + solve( n - 2 ) + solve( n - 3 );
}

int main()
{
	while ( true )
	{
		int n;
		cin >> n;

		if ( n == 0 )
		{
			break;
		}

		memo.resize( n + 1 );
		fill( ALL( memo ), -1 );

		cout << solve( n ) / 3650 + 1 << endl;
	}

	return 0;
}

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

#define INF 1 << 30;
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){

	int n;
	while(cin >> n && n){
		// 段数
		int dp[32];
		rep(i, n) dp[i] = INF;
		
		dp[0] = 1;
		dp[1] = 2;
		dp[2] = 4;

		for(int i = 3; i < n; i++){
			dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
		}

		cout << dp[n-1]/365/10  + 1<< endl;
	}
	return 0;
}

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

int main()
{
  long dp[40];
  fill_n(dp, 40, 0);

  dp[0] = 1;

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

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

C++: #include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

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


#define MAX_N 31
int n;
int dp[MAX_N];

int solve() {
  // clear
  rep(i, MAX_N) dp[i] = 0;
  // dp
  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];
  }
  return dp[n];
}


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

    int ans = solve();
    int wer = ans / 3650;
    if (ans % 3650 != 0) wer += 1;
    cout << wer << '\n';
  }
  return 0;
}

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

int main(){
  int dp[45] = {};



  for(int i=0;i<45;i++){
    dp[i] =0;
  }

  dp[0] = 1;

  for(int i=0;i<40;i++){
    dp[i+1] += dp[i];
    dp[i+2] += dp[i];
    dp[i+3] += dp[i];
  }

  while(1){
    int a;
    a=0;
    cin >> a;
    if(a ==0)break;
    cout << dp[a] / 3650 + 1 << endl;

  }
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;

typedef long long ll;

#define rep(i,n) for(int i=0;i<(n);i++)

ll dp(ll n,vector<ll> &memo){
    if(n==0) return 1;
    else if(n<0) return 0;
    if(memo[n]!=-1) return memo[n];
    return memo[n]=dp(n-1,memo)+dp(n-2,memo)+dp(n-3,memo);
}

int main(){
    int N;
    vector<ll> ans(999999,-1);
    for(int i=0; ;i++){
        vector<ll> memo(999999,-1);
        memo[0]=1,memo[1]=1;
        int a;
        cin>>a;
        if(a==0) break;
        else{
            ll num=dp(a,memo);
            if(num%10==0)num=num/10;
            else num=num/10+1;
            if(num%365==0)ans[i]=num/365;
            else ans[i]=num/365+1;
        }
    }
    for(int i=0; ;i++){
        if(ans[i]==-1) break;
        cout<<ans[i]<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int n;
	int a[33];

	cin >> n;
	a[0] = a[1] = 0;
	a[2] = 1;
	for(int i = 3;i < n+3;i++){
		a[i] = a[i-3] + a[i-1] + a[i-2];
	}
	int res = a[n+2]/10/365;
	if(a[n+2]% 3650 != 0)
		res ++;
	cout << res << endl;
	return 0;
}

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

int main(void){
  int n, p[31] = {1, 1, 2};
  for(int i = 3; i <= 30; i++){
    p[i] = p[i-1] + p[i-2] + p[i-3];
  }
  while(true){
    cin >> n;
    if(n == 0) break;
    cout << (p[n] / 10 / 365) + 1 << endl;
  }
  return 0;
}

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

// a[n]を求める問題

int f(int n){   //再帰関数
    if(n == 1) return 1;
    if(n == 2) return 2;
    if(n == 3) return 4;
    // f(n) = f(n-1) + f(n-2) + f(n-3)
    return f(n-1) + f(n-2) + f(n-3);
}
int main(void){
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        cout << (f (n) / 3650)+1 << endl;
    }
}

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

int main(void)
{
    int n;
    long long a[30] = {1, 2, 4};
    for (int i = 3; i < 30; i++) 
        a[i] = a[i - 1] + a[i - 2] + a[i - 3];
    while (cin >> n && n) 
        cout << 1 + a[n-1] / 3650 << endl;

    return 0;
}