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 <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;

const int INF = 1 << 29;
typedef pair<int, int> P;

int n;

int main(void)
{
	while(cin >> n && n)
	{
		int dp[33] = {0};
		dp[0] = dp[1] = dp[2] = 1;
		for (int d = 0; d < n; d++)
		{
			for (int i = 0; i < 3; i++)
			{
				dp[d + i + 1] += dp[d];
			}
		}
		cout << (dp[n - 1] - 1) / 10 / 365 + 1 << endl;
	}
	return 0;
}

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

int main(){
	int t[40];
	t[0] = 1;
	int n;
	cin >> n;
	while(n!=0){
		for(int i = 1; i < 40; i++)t[i] = 0;
		for(int i = 0; i < n; i++){
			t[i+1] += t[i];
			t[i+2] += t[i];
			t[i+3] += t[i];
		}
		cout << ceil((double)t[n]/3650) << endl;
	cin >> n;
	}
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int main() {
  int a, kai[31];
  kai[0] = 1;
  kai[1] = 1;
  kai[2] = 2;
  for (int i = 3; i < 31; i++) {
    kai[i] = kai[i - 1] + kai[i - 2] + kai[i - 3];
  }
  rep(i, 30) kai[i] = (kai[i] + 3659) / 3650;
  while (cin >> a, a)
    cout << kai[a] << endl;
  return 0;
}

C++: // 2011/02/12 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int memo[31];
	memo[0] = 0;
	memo[1] = 1;
	memo[2] = 2;
	memo[3] = 4;
	for(int i=4; i<=30; i++)
		memo[i] = memo[i-1]+memo[i-2]+memo[i-3];

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

		cout << ((memo[n]+9)/10+364)/365 << endl;
	}

	return 0;
}

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

typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int dy[] = { 0, 0, 1, -1 };
int dx[] = { 1, -1, 0, 0 };

ll A, B, C, D, E, F, G, H, I, J, K, L, M,
N, O, P, Q, R, S, T, U, V, W, X, Y, Z;

//* ?????????n??????????????\??????????????????????????????????????????
template <typename T>
vector<T> INP(ll n)
{
	vector<T> x;
	REP(i, n) {
		T tmp; cin >> tmp;
		x.push_back(tmp);
	}
	return x;
}
//* n??????1????????????????????\?????????????????????????????¨??????????????????
vector<char> SPRIT_STRING(ll n)
{
	string str; cin >> str;
	vector<char> cs(n);
	REP(i, n) cs[i] = str[i];
	return cs;
}
//* ??§?¨?nx, ny???Width,Height?????????????????????????????????????????§??????
inline bool rangeCheck2D(int nx, int ny, int Width, int Height)
{
	return nx >= 0 and nx < Width and ny >= 0 and ny < Height;
}
//* ?´???°?????? is_prime<unsigned>(N)
template<typename T, std::enable_if_t<std::is_unsigned<T>::value, std::nullptr_t> = nullptr>
bool is_prime(const T n) {
	if (n < 4) return n == 2 || n == 3;
	if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false;
	for (T i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false;
	return true;
}

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2007
namespace makePurseLight {
	void makePurseLight()
	{
		cin >> N;
		int n[] = { 500, 100, 50, 10 };
		while (true) {
			int num[4];
			REP(i, 4) cin >> num[3-i];
			int sum = 0;
			REP(i, 4) sum += n[i] * num[i];
			int ret = sum - N;
			vector<int> cnt(4);
			while (ret > 0) {
				REP(i, 4) if (ret >= n[i]) {
					ret -= n[i]; cnt[i]++;
					break;
				}
			}
			REP(i, 4) {
				int ri = 3 - i;
				int ans = num[ri] - cnt[ri];
				if (ans > 0) cout << n[ri] << " " << ans << endl;
			}
			cin >> N;
			if (N == 0)
				break;
			else
				cout << endl;
		}
	}
}

namespace kannondou {
	void kannondou()
	{
		cin >> N;
		while (N) {
			ll 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];
			ll day = dp[N - 1] / 10 + ((dp[N - 1] % 10 == 0) ? 0 : 1);
			ll year = day / 365 + ((day % 365) ? 0 : 1);
			cout << year + 1 << endl;
			cin >> N;
		}
	}
}

// CodeForces
namespace foxAndCardGame {
	void foxAndCardGame()
	{
		cin >> N;
		int nums[105][105];
		int in[105];
		REP(i, N) {
			int c; cin >> c;
			in[i] = c;
			REP(j, c) {
				cin >> nums[i][j];
			}
		}
		int cielA = 0, jiroA = 0;
		vector<int> odds;
		REP(i, N) {
			int n = in[i];
			REP(j, n / 2) cielA += nums[i][j];
			if (n % 2 == 0) {
				if (n > 1) FOR(j, n / 2, n) jiroA += nums[i][j];
			}
			else {
				if (n > 2) FOR(j, n / 2 + 1, n) jiroA += nums[i][j];
				odds.push_back(nums[i][n / 2]);
			}
		}
		sort(odds.rbegin(), odds.rend());
		REP(i, odds.size()) {
			if (i % 2 == 0)
				cielA += odds[i];
			else
				jiroA += odds[i];
		}
		cout << cielA << " " << jiroA << endl;
	}
}

int main()
{
	kannondou::kannondou();
	return 0;
}

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

int main() {
  int n;
  while (cin >> n && n) {
    int dp[40];
    for (int i = 0; i < 40; i++) {
      dp[i] = 0;
    }
    dp[0] = 1;
    for (int i = 0; i <= n; i++) {
      dp[i+3] += dp[i];
      dp[i+2] += dp[i];
      dp[i+1] += dp[i];
    }
    cout << (dp[n] + 3649) / 3650 << endl;
  }
}

C++: #include<cstdio>
int getPattern(int);

int main(){

  int n;
  while(1){
    scanf("%d",&n);
    if(n==0) break;
    printf("%d\n",getPattern(n)/3650);
  }
  return 0;
}

int getPattern(int n){

  int dp[n];
  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];

  return ((dp[n-1]%3650)!=0) ? dp[n-1]+3650 : dp[n-1];
}

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

int main()
{
	int A[30]; //i???????????§????????????
	int N;
	
	A[0]=1;
	A[1]=1;
	A[2]=2;
	A[3]=4;

	int i;
	for(i=4;i<31;++i){
		A[i]=A[i-1]+A[i-2]+A[i-3];
	}

	while(cin>>N && N){
		cout<<((A[N]+9)/10+364)/365<<endl;
	}

	return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std ;
int main()
{
	int n ;
	float dp[ 30 ] ;
	while( cin >> n , n )
	{
		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 ] ;
		}
		n-- ;
		cout << ceil( dp[ n ] / 3650 ) << endl ;
	}
	return 0 ;
}

C++: #include <iostream>

using namespace std;

int n;
int memo[366];

int dfs(int num)
{
	
	int sum = 0;

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

	if(num == n)
	{
		return 1;
	}

	if(num < n)
		sum += dfs(num + 1);

	if(num < n)
		sum += dfs(num + 2);

	if(num < n)
		sum += dfs(num + 3);

	memo[num] = sum;

	return sum;
}

int main()
{

	while(1)
	{
		cin >> n;

		for(int i = 0; i <= 31; i++)
		{
			memo[i] = -1;
		}

		if(n == 0)
		{
			break;
		}

		cout << dfs(0)/10/365+1 << endl;
	}
}

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

using namespace std;

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

typedef long long ll;

int main() {
    int dp[31];
    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];
    }
    int n;
    while(cin >> n, n){
        cout << dp[n]/365/10+1 << endl;
    }
}