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>
using namespace std;

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

C++: 
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

typedef long long ll;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

ll d[40];
void solve(){

}
void show(){
  for(int i=0;i<40;i++){
    cout<<i<<":"<<d[i]<<endl;
  }
}
void init(){
  fill(d,d+40,0);
  d[1]=1;
  d[2]=2;
  d[3]=4;
  for(int i=4;i<31;i++){
    d[i]=d[i-3]+d[i-2]+d[i-1];
  }
}
int main(){
  int n;
  init();
  while(cin >> n,n){
    cout<<(d[n]/3650)+1<<endl;
  }
  return 0;
}

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

using namespace std;

struct Memo
{

  int count;

  Memo()
  {
    count = 0;
  }

};

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;

  if(step_num - 3 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 3,3);
  if(step_num - 2 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 2,2);
  if(step_num - 1 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 1,1);

  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>
using namespace std;

int main() {
	int a[30];
	a[0] = 1;
	a[1] = 1;
	a[2] = 2;
	for ( int i = 3; i <= 30; i++ )
		a[i] = a[i - 1] + a[i - 2] + a[i - 3];
	int n;
	while ( cin >> n ) 
		cout << a[n] << endl;
}

C++: #include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
static const int MAX_N = 30;
int dp[MAX_N+1];
int main() {
    int n;
    dp[0] = dp[1] = 1;
    dp[2] = 2;
    for(int i = 3; i <= 30; i++) dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
    for (;;) {
        scanf("%d", &n);
        if (n == 0) break;
        printf("%d\n", dp[n] / 3650 + 1);
    }
    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 <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <unordered_set>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 1000000009;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()

int main()
{
	int n;
	vector<int> dp(35);
	dp[0] = 1;
	REP(i, 30)REP(j, 3)dp[i + 1 + j] += dp[i];
	while (cin >> n && n)
	{
		cout << (dp[n] / 10 / 365 + 1) << endl;
	}
	return 0;
}

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

int fib(int n, int num);
int dx[31];

int main(){
	int n;
	dx[1] = 1;
	dx[2] = 2;
	dx[3] = 4;
	while(cin >>n){
		if(n == 0) break;
		int cnt = fib(n, 4), day, year;
		day = cnt / 10;
		if(cnt % 10 != 0) day++;
		year = day / 365;
		if(day % 10 != 0) year++;
		cout <<year <<endl;
	}
	return 0;
}

int fib(int n, int num){
	if(n <= 3){
		return dx[n];
	}
	else if(num <= n){
		dx[num] = dx[num - 3] + dx[num - 2] + dx[num - 1];
		if(num == n){
			return dx[num];
		} else{
			fib(n, ++num);
		}
	}
}

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] + 3649) / 3650;
  while (cin >> a, a)
    cout << kai[a] << endl;
  return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cmath>

int memo[40];

int main() {
    memo[0] = 1;
    memo[1] = 1;
    memo[2] = 2;
    int n;
    for (int i = 3; i < 31; i++) {
        memo[i] = memo[i - 1] + memo[i - 2] + memo[i - 3];
    }
    while (true) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        }
        printf("%d\n", int(ceil(double(memo[n]) / 3650)));
    }
    return 0;
}

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

int num(int n);

int main()
{
  string s;
  cin >> s;
  cout << num(stoi(s)) <<endl;
}

int num(int n){
  if(n<0)return 0;
  return num(n-1)+num(n-2)+num(n-3);
}

C++: #include<iostream>

using namespace::std;

int fib(int n) {
	
	if (n == 0) {
		return 0;
	}
	if (n == 1) {
		return 1;
	}
	if (n == 2) {
		return 2;
	}
	if (n == 3) {
		return 4;
	}


	int x[100];
	x[0] = 0;
	x[1] = 1;
	x[2] = 2;
	x[3] = 4;

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

/*
int main() {

	cout << fib(7);
	getchar();
	return 0;
	
}
*/
//int main() {
//	int N = 0;
//	cin >> N;
//
//	int n[1001];
//	int rin[1001] ;
//	int max;
//	for (int j = 0; j < N; j++) {
//		cin >>n[j];
//	}
//	
//	for (int j = 0; j < N; j++) {
//		
//		rin[j] = 1;
//			for (int k = 0; k < j; k++){
//				if (n[k] < n[j] && rin[j] <= rin[k]) {
//
//					rin[j] += 1;
//				}
//			}
//		
//	}
//
//	max = rin[0];
//	for (int j = 0; j < N; j++) {
//		if (max < rin[j]) {
//			max = rin[j];
//		}
//	}
//	cout << max;
//
//	getchar();
//	getchar();
//	return 0;
//}

int main() {
	/*int n;
	cin >> n;
	int ans;
	int ama;

	ans = n / 3;
	ans = ans * 4;

	if (n % 3 == 1) {
		ans +=
	}
	else if (n % 3 == 2) {

	}*/
	int a[100];
	int i= 0;

	while (true) {
		cin >>a[i];
		if (a[i] == 0)
			break;
		i++;
	}

	for (int j = 0; j < i; j++) {
		if (a[j] != 0) {
			cout << fib(a[j])/10/ 365 + 1 << endl;
		}
		else {
			cout <<0 << endl;
		}
	}

	getchar();
	getchar();
	return 0;

}

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

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

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

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