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<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int dan[45]={0},nen[45]={0};
    int n;
    dan[1]=1;
    nen[1]=1;
    dan[2]=2;
    dan[3]=4;
    for(int i=4;i<=35;i++)
    {
        dan[i]=dan[i-1]+dan[i-2]+dan[i-3];
    }
    while(cin>>n)
    {
        nen[n]=dan[n]/3650;
        if(dan[n] % 3650 != 0)
        {
            nen[n]++;
        }
        if(n==0)break;
        cout<<nen[n]<<endl;
    }
    return 0;
}

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

int limit;
int dfs( int n )
{
	if ( n == limit ) return 1;
	if ( n > limit ) return 0;
	int count = 0;
	for ( int i = 1; i <= 3; i++ )
	{
		count += dfs( n+i );
	}
	return count;
}

int calc( int n )
{
	limit = n;
	int count = dfs( 0 );
	return count / 10;
}

int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		int days = calc( n );
		cout << days/365+1 << endl;
	}
	return 0;
}

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

long long A[128], N;
int main(){
	A[0] = 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];
	}

	for (;;){
		cin >> N;
		if (N == 0)break;
		cout << (A[N] / 3650) + 1 << endl;
	}
}

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

int A[128],N;
int main() {
	A[0] = 1;
	cin >> N;
	while(N != 0) {
		for(int i=0; i<N; ++i) {
			if(A[i] ==0) {
				A[i] = A[i-1];
				if(i>1) A[i] += A[i-2];
				if(i>2) A[i] += A[i-3];
			}
		}
		cout << (A[N]/10 + 364)/365 << endl;
		cin >> N;
	}
}

C++: #include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int tri[31];
	tri[0] = tri[1] = 1;
	tri[2] = 2;
	reep(i, 3, 31)
		tri[i] = tri[i-1] + tri[i-2] + tri[i-3];
	
	int n;
	while(scanf("%d", &n), n){
		printf("%d\n", (tri[n]+3649)/3650);
	}
	
	return 0;
}

C++: //
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int f(int n)
{
  switch(n){
  case 1:
    return 1;
    break;
  case 2:
    return 2;
    break;
  case 3:
    return 4;
    break;
  default:
    int a[30];
    a[0]=1;
    a[1]=2;
    a[2]=4;
    for(int i=3;i<n;++i){
      a[i]=a[i-1]+a[i-2]+a[i-3];
    }
    return a[n-1];
    break;
  }
}

int tenjyou(double n)
{
  if(n==(int)n){
    return (int) n;
  }else{
    return (int) n+1;
  }
}

int main()
{
  int n;
  int m=0;
  vector<int> answer;
  while(cin>>n&&n>0){
    double day,year;
    day=tenjyou(f(n)/10.0);
    year=tenjyou(day/365.0);
    answer.push_back(year);
    m+=1;
  }
  for(int i=0;i<m;++i){
    cout<<answer[i]<<endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    vector<int> dp(40);
    dp[0] = 1;
    for(int i=0; i<30; i++){
        dp[i+1] += dp[i];
        dp[i+2] += dp[i];
        dp[i+3] += dp[i];
    }
    
    while(1){
        int n; cin >> n;
        if(n==0) return 0;
        cout << ((dp[n] + 9)/ 10 + 364) / 365 << endl;
    }
    
    
    return 0;
}

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

using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

#define MOD 1000000007

int N;

int main(){

    int n;

    cin >> n;

    vector<int> nlist;

    while(n != 0){
        nlist.push_back(n);
        cin >> n;
    }

    vector<int> res(30+1, 0);

    res[0] = 0;
    res[1] = 1;
    res[2] = 2;
    res[3] = 4;

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

    for(int i = 0; i < nlist.size(); i++){
        cout << res[nlist[i]]/(365*10) + 1 << endl;
    }
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int A[128], N;
int main(){
  A[0] = 1;
  while(cin >> N && N > 0){
    for(int i=1; i<=32; i++){
      A[i] = A[i-1];
      if(i>=2) A[i] += A[i-2];
      if(i>=3) A[i] += A[i-3];
    }
    ll days = (A[N]+9) / 10;
    ll ans = (days+364) / 365;
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

int foot(int);

int main() {

	int n;
	vector<int>floor;

	
	cin >> n;
	while (n != 0) {
		floor.push_back(n);
		cin >> n;
	}
	floor.push_back(0);


	int i = 0;
	while (floor[i] != 0) {

		int res = 0;
		res = foot(floor[i]) / 3650;
		if( foot(floor[i]) % 3650 != 0) res++;

		cout << res << endl;
		i++;
	}

	cin >> n;


	return 0;
}

int foot(int n) {


	if (n == 1)return 1;
	if (n == 2)return 2;
	if (n == 3)return 4;
	if (n < 1)return 0;

	return foot(n - 1) + foot(n - 2) + foot(n - 3);


}

C++: #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int step(int s, vector<int> &dp, int n) {
	int cnt = 0;
	if (s == n) return 1;
	for (int i = 1; i <= 3; i++) {
		if (s + i <= n) {
			if (dp[s + i] == -1)
				cnt += step(s + i, dp, n);
			else
				cnt += dp[s + i];
		}
	}
	dp[s] = cnt;
	return cnt;
}

int main(void) {
	int n;
	vector<int> dp;
	vector<int> res;
	dp.resize(31, -1);
	while (cin >> n, n) {
		int cnt = 0;
		for (int i = 1; i <= 3; i++)
			cnt += step(i, dp, n);
		dp.clear();
		dp.resize(31, -1);
		res.push_back(cnt / 10 / 365 + 1);
	}
	for (int i = 0; i < res.size(); i++)
		cout << res[i] << endl;
}

C++: #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define pb push_back
#define debug(x) cout<< #x <<": "<<x<<endl
#define debug2(x,y) cout<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector< T > >;

int main() {
  vi a(31, 0);
  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];
  }
  const int try_per_year = 365*10;
  while (true) {
    int steps;
    cin >> steps;
    if (steps == 0) { break; }
    printf("%d\n", (a[steps]+try_per_year-1)/try_per_year);
  }

  return 0;
}