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<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int n;
LL memo[31];

LL solve(int cnt){
	if(memo[cnt] != -1) return memo[cnt];
	if(cnt >= n) return cnt > n? 0 : memo[cnt] = cnt == n;
	LL res1 = memo[cnt] = solve(cnt + 1);
	LL res2 = memo[cnt] = solve(cnt + 2);
	LL res3 = memo[cnt] = solve(cnt + 3);
	return memo[cnt] = res1 + res2 + res3;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	while(1){
		rep(i,31)
			memo[i] = -1;
		cin >> n;
		if(n == 0) break;
		LL ans = solve(0);
		ans = ans / 10.0 / 365.0 + 1;
		cout << ans << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
#define MAX_N 105
using namespace std;
bool debug=false;

int dfs(int n,int i){
  int cnt=0;
  if(n==i)return 1;
  else if(i>n)return 0;
  else{
    cnt+=dfs(n,i+1);
    cnt+=dfs(n,i+2);
    cnt+=dfs(n,i+3);
    return cnt;
  }
}

int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    cout<<dfs(n,0)/3650+1<<endl;
  }
  return 0;
}

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

using namespace std;

int cost;
int memo[31];
bool isuse[31];

int saiki(int n)
{
	
	if(n <= 0){
		cost++;
	}
	if(n > 0){
		if(n-1 >= 0){
			saiki(n-1);
		}
		if(n-2 >= 0){
			saiki(n-2);
		}
		if(n-3 >= 0){
			saiki(n-3);

		}
	}
	/*
	else if(n == 0){
		cost++;
		return;
	}
	*/
}

int main()
{
	for(;;){
		int n, i;
		cost = 0;
		
		cin >> n;
		if(n == 0){
			break;
		}
		
		saiki(n);
		
		for(i = 1;; i++){
			cost -= 3650;
			if(cost <= 0){
				break;
			}
		}
		
		cout << i << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <utility>
#include <queue>
#define INF 1000000007

using namespace std;
typedef long long int ll;

int main(){
    vector<int> dp(31,0);
    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];
    }
    for (;;) {
        int n;
        cin >> n;
        if(n==0) break;
        int ans = dp[n]/(10*365);
        if(dp[n]%365>0) ans++;
        cout << ans <<endl;
    }
}

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 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 <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;



int main(){
	vector<int>  stairs;
	stairs.push_back(1);
	stairs.push_back(1);
	stairs.push_back(2);
	
	for(int i = 3; i < 31; i++){
		int tmp = stairs[i - 1] + stairs[i - 2] + stairs[i - 3];
		stairs.push_back(tmp);
	}

	int n = 0;
	while(cin >> n && n != 0){
		int tmp = 0;
		if(stairs[n] / 10 == 0) tmp = 1;
		else tmp = stairs[n] / 10;
		if(tmp % 365 == 0){
			cout << tmp / 365 << endl;
		}
		else{
			cout << tmp / 365 + 1 << endl;
		}
	}

	return 0;
}

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

long long dp[30] = {1,1,2};
int ans[30];
int n;

int main(){
  
  for(int i = 3 ; i < 30 ; i++){
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
  }
  for(int i = 0; i < 30 ; i++){
    ans[i] = dp[i] / 10;
    if(dp[i] % 10 != 0) ans[i]++;
    ans[i] = ans[i] / 365 ;
    if(ans[i] % 365 != 0) ans[i]++;
    if(ans[i] == 0) ans[i]++;
  }

  while(cin >> n, n != 0){

    cout << ans[n] << endl; 
  }
  
  return 0;
}

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

long long calc(int x){
    if(x < 0) return 0;
    if(x == 0) return 1;
    return calc(x - 1) + calc(x - 2) + calc(x - 3);
}

int main(){
    long long n;
    while(cin >> n, n){
        cout << (calc(n) + 3649) / 3650  << endl;
    }
}

C++: #include <iostream>
using namespace std;
int n , now = 0;
int saiki(int now){
	if( now == n )
		return 1;
	if( now > n )
		return 0;
	int res = 0;
	res += saiki(now+1)+saiki(now+2)+saiki(now+3);
	return res;
}
int main(){
	while(1){
		int x=0;
		cin >> n;
		if( n==0 ) break;
		int count = saiki(0);
		int co = count / 10;
		if( count%10 > 0 )
			co ++;
		x = co / 365 ;
		if(co%365>0)
			x ++;
		cout << x << endl;
	}
}

C++: #include<iostream>

struct Memo
{

	int count;
	bool flag;

	Memo()
	{

		count = 0;
		flag = false;

	}

};

using namespace std;

Memo memo[31][4];

int ProgressNumberOfYears(int step_num,int step_length)
{

	int kind_count = 0;

	if(memo[step_num][step_length].flag && step_length != 0) return memo[step_num][step_length].count;
	else if(step_num == 0) return 1;
	else if(step_num < 0) return 0;

	for(int i = 1; i < 4; ++i)	kind_count += ProgressNumberOfYears(step_num - i,i);

	Memo temp;

	temp.count = kind_count;
	temp.flag = true;

	memo[step_num][step_length] = temp;

	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;

}