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 <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;
ll const MAX = 30;
ll const DAYS = 3650;

int main() {
  vector<ll> dp(MAX+1, 0);
  dp[0] = 1;

  repI(i, 1, MAX+1) {
    dp[i] += dp[i-1];
    if (i > 1) dp[i] += dp[i-2];
    if (i > 2) dp[i] += dp[i-3];
  }
  ll n;

  while(cin >> n && n) {
    cout << dp[n] / DAYS + (dp[n] % DAYS != 0) << endl;;

  }
  return 0;
}

C++: #include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <map>

using namespace std;
typedef long long LL;
#define REP(i,N) for(int i = 0; i < (int)N; i++)
LL dp[35];
int main(){
	int n;
	dp[0] = 1;
	for(int i=1;i<=30;i++){
		for(int j=1;j<=min(3,i);j++){
			dp[i] += dp[i-j];
		}
	}
	while(cin >> n){
		if(n==0)break;
		cout << ((dp[n]/3650)  + (dp[n]%3650 == 0 ?0:1)  )<< endl;
	}
	return 0;
}

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

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

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

int main(void)
{
	int n;
	while(cin >> n && n)
	{
		vector<int> dp(n + 5);
		dp[0] = 1;
		for (int i = 0; i < n; i++)
		{
			dp[i + 1] = dp[i + 2] = dp[i + 3] = dp[i];
		}
		cout << (dp[n] / 365 + !!(dp[n] % 365)) << endl;
	}
	return 0;
}

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

using namespace std;

struct Memo
{

  int count;
  bool flag;

  Memo()
  {
    count = 0;
    flag = false;
  }

};

Memo memo[31][4];

int ProgressNumberOfYears(int step_num, int step_kind)
{

  int kind_count = 0;

  if(step_num == 0) return 1;
  else if(memo[step_num][step_kind].count) return memo[step_num][step_kind].count;

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

  memo[step_num][step_kind].count = kind_count;

  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;

}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>

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;

}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };

LL dp[ 31 ];
LL ans, day, n, cnt;

LL solve( int now ) {
	if ( now < 0 ) {
		return 0;
	}
	if ( dp[ now ] >= 0 ) {
		return dp[ now ];
	}
	if ( now == 0 ) {
		return dp[ now ] = 1;
	}
	LL res = 0;
	for ( int i = 1; i <= 3; i++ ) {
		res += solve( now - i );
	}
	return dp[ now ] = res;
}

int main() {
	memset( dp, -1, sizeof( dp ) );
	while ( ~scanf( "%d", &n ) && n ) {
		day = solve( n );
		ans = day / 3650 + !!( day % 3650 );
		printf( "%lld\n", ans );
	}
	return 0;
}

C++: #include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int dp[31];

int main() {
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	FOR(i, 3, 31) {
		dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
	}
	int N;
	while(scanf("%d", &N), N) {
		printf("%d\n", dp[N]/10/365 + 1);
	}
	return 0;
}

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

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

using namespace std;

typedef long long ll;

ll dp[31];

int main(){
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	for(int i = 3; i <= 30; ++i){
		dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
	}
	rep(i, 31){
		dp[i] = (dp[i] + 3649) / 3650;
	}
	while(1){
		int n;
		scanf("%d", &n);
		if(n == 0){
			break;
		}
		printf("%lld\n", dp[n]);
	}
	return 0;
}

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

int main(){
  int n;
  int a[31]={1,1,2};
  for(int i=3;i<=30;i++ ){
    a[i]=a[i-1]+a[i-2]+a[i-3];
  }

  while(cin>>n,n){
    cout << (a[n]/10/365 + 1) << endl;
  }
}