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>
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n[40];
int dp[40] = {0};

int input(){
    int i=0;
    while(1){
        int x;
        cin >> x;
        if(x == 0) break;
        n[i] = x;
        i++;
    }
    return i;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sz = input();
    dp[1] = 1;
    dp[2] = 2;
    dp[3] = 4;
    for(int i=1;i<31;i++){
        dp[i+3] = dp[i] + dp[i+1] + dp[i+2];
    }
    for(int i=0;i<sz;i++){
        cout << (dp[n[i]]%3650>0 ? dp[n[i]] / 3650 + 1 : dp[n[i]] / 3650) << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}

typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
long long dp[31] = {0};
void func(int n){
	fill_n(dp, 31, 0);
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;
	for(int i = 4; i < 30; i++){
		dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
	}
}


int main(void){
	func(30);
	int n;
	while(cin >> n, n){
		int ans = 0;
		if(dp[n] % 3650 != 0)ans++;
		ans += (dp[n]/3650);
		cout << ans << endl;
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

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

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, n, m) for (ll i = n; i < m; i++)
#define RFOR(i, n, m) for (ll i = n - 1; i >= m; i--)

void output() { std::cout << std::endl; }
void input() {}

template <class Head, class... Tail> void input(Head &&head, Tail &&... tail) {
  std::cin >> head;

  input(std::forward<Tail>(tail)...);
}

template <class Head, class... Tail> void output(Head &&head, Tail &&... tail) {
  std::cout << head;
  if (sizeof...(tail))
    std::cout << " ";

  output(std::forward<Tail>(tail)...);
}

int main() {
  do {

    ll n;
    input(n);
    if (!n)
      break;

    vi s(n + 1, 0);
    s[0] = 1;
    FOR(i, 1, n + 1) {
      if (i > 2)
        s[i] += s[i - 3];
      if (i > 1)
        s[i] += s[i - 2];
      s[i] += s[i - 1];
    }

    output((s[n] - 1) / 3650 + 1);

  } while (true);
  return 0;
}

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

int dp[30];

void makedp(){
  dp[0]=1;
  dp[1]=2;
  dp[2]=4;
  for(int i=3;i<30;i++)
    dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
}

int solve(int n){
  if(n!=1) n--;
  int day = dp[n]/10;
  if(dp[n]&10) day++;

  int year = day/365;
  if(day&365) year++;

  return year;
}

int main(){
  makedp();
  for(;;){
    int n;
    cin >> n;
    if(!n) break;
    cout << solve(n) << endl;
  }
}

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

int main() {
	int n;
	while (1) {
		int temp[40] = {};
		cin >> n;
		if (n == 0) break;

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

		cout << temp[n]/3650 + 1 << endl;

	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <stack>

#define rep(i,x) for(int i=0;i<x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rep_to(a,i,x) for(int i=a;i<x;i++)

using namespace std;

int main()
{
	int num[1000]={};
	int add[1000]={};
	int n;
	while(1){
	cin>>n;
	if(n==0)break;
	double sum=1;
	rep(i,n)
	{
		if(i<=3)add[i]=i;
		else add[i]=(add[i-3]+add[i-2]+add[i-1]);
		sum+=add[i];
	}
	cout<<ceil(sum/3650)<<endl;
}

	return 0;
}

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


int main(){
	int a[128];
	a[0]=a[1]=1;
	for(int i=1 ; i<32 ; i++){
		a[i]=a[i-1];
		if(i>1) a[i]+=a[i-2];
		if(i>2) a[i]+=a[i-3];
	}
	int n;
	while(cin>> n){
		if(n!=0){
		int day = (a[n]-a[n]%10)/10 + 1;
		int year =(day - day %365 )/365 + 1;
		cout<<year<<endl;
		}
	}


}

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

int fib[100];

int fibonacci(int n){
  if(!fib[n]) fib[n] = fibonacci(n-1) + fibonacci(n-2) + fibonacci(n-3);
  return fib[n];
}

int main(){
  int n;
  memset(fib, 0, sizeof(fib));
  fib[0] = fib[1] = 1;
  fib[2] = 2;
  while((cin >> n), n){
    cout << (fibonacci(n)/3650 + 1) << endl;
  }
  return 0;
}

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

int main()
{
	int n, 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);
		if(p[n] % (10 * 365) != 0){
			y++;
		}
		cout << y << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int dp[31][31];
	int n;
while(1){
	cin >> n;
        if(n==0)break;
	memset(dp, 0, sizeof(dp));
	dp[1][1] = 1;
	dp[1][2] = 1;
	dp[1][3] = 1;
	for (int i = 1; i <= 27; i++){
		for (int i2 = 1; i2 <= 27; i2++){
			dp[i + 1][i2 + 1] += dp[i][i2];
			dp[i + 1][i2 + 2] += dp[i][i2];
			dp[i + 1][i2 + 3] += dp[i][i2];
		}
	}
	int sum=0;

	for (int i = 0; i < 30; i++){
		sum += dp[i][n];
	}
	cout << sum / 10/365+1<<endl;
}
}

C++: 

#include <algorithm>
#include <iostream>
using namespace std;

int A[128], n; 
int main() {
	while(cin >> n && n >0){
		A[0] = 0;
		A[1] = 1;
		A[2] = 2;
		for (int i=3; i<=n+10; ++i) {
			A[i] = A[i-1]+A[i-2]+A[i-3];
		}
		int x = (A[n]+9)/10;
		int y = (x+364)/365;
	cout << y <<endl;
	}
}