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 <array>
#include <cmath>
using namespace std;

int main() {
    array<long long, 31> stairs{};
    {
        stairs[0] = 1;
        for (auto step = 0; step <= 30; step++)
            for (auto walk = 1; walk <= 3; walk++) 
                if (step + walk <= 30)
                    stairs[step + walk] += stairs[step];
    }
    int n;
    while (cin >> n, n)
        cout << ceil(static_cast<double>(stairs[n]) / 3650.) << endl;
    return 0;
}

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

int main() {
  int n;
  while (cin >> n, n) {
    vector<int> dp(n + 1, 1);
    dp[1] = 1;
    dp[2] = 2;
    for (int i = 3; i < n + 1; ++i) dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
    cout << (dp[n] + 3650 - 1) / 3650 << 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;
 
    // Your code here!

        cout << (f(n) /3650 )+1 << endl; 
  }
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	vi dp(31);
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;

	FOR(i, 4, 31) {
		dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
	}

	int n;

	while(cin >> n, n) {
		cout << (dp[n]/3650)+1 << endl;
	}
}

C++: #include<iostream>
#include<stdio.h>
#include<memory.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++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	vector<LL> a(32);
	a[1] = 1; a[2] = 2; a[3] = 4;
	FOR(i, 4, 32) {
		a[i] = a[i - 1] + a[i - 2] + a[i - 3];
	}
	while (true) {
		LL n; cin >> n;
		if (n == 0)break;
		LL day = (a[n] + 9) / 10;
		cout << (day + 364) / 365 << endl;
	}
}

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

#define NMAX 30

int n;
int dp[NMAX+1];

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

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

	
	int dn[33];
int main(){
	int n=0;
	dn[0]=1;
	for(int i=0;i<30;i++){
		for(int j=1;j<=3;j++){
		dn[i+j]+=dn[i];
		}
	}
	
	while(true){
	cin >> n;
	if(n==0)
		break;
	int l=dn[n]/(365*10);
	if(dn[n]%(365*10)!=0)
		l++;

	cout << l << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
/* 変数名を被らせない
   デバッグコードを取り除く */
#define ANSWER(x) cout<<x<<endl
#define debug(x) cout<<#x<<": "<<x
const int MAX_INT = 1000000;
int dp[31];
int n;
int solve(int a);
int main(){
  while(1){
    memset(dp,-1,sizeof(dp));
    cin >> n;
    if(n==0)break;
    cout << (solve(n)/10-1)/365+1 << endl;
  }
}
int solve(int a){
  if(dp[a] != -1)return dp[a];
  else{
    if(a == 0)return 1;
    else if(a < 0)return 0;
    else return dp[a] = solve(a-1)+solve(a-2)+solve(a-3);
  }
}

C++: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
ll dp[31];
void mainmain(){
	dp[1]=1;
	dp[2]=2;
	dp[3]=4;
	reep(i,4,31){
		rep(j,3){
			dp[i]+=dp[i-j-1];
		}
	}
	// reep(i,4,7){
		// cout<<dp[i]<<endl;
	// }
	// rep(i,35){
		// cout<<i<<" "<<i*3650<<endl;
	// }
	// rep(i,31){
		// cout<<i<<" "<<dp[i]<<endl;
	// }
	int n;
	while(cin>>n){
		ll t=dp[n]-1;
		// cout<<t<<endl;
		t/=3650;
		cout<<t+1<<endl;
	}
	// int tt=7299;
	// tt/=3650;
	// cout<<tt+1<<endl;
}

}
main() try{
    mainmain();
}
catch(...){
}

C++: #include<stdio.h>
int n;

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

int main()
{
    while(1)
    {
        scanf("%d",&n);
        if(n==0)break;
        printf("%d\n",(((fn(n)+10-1)/10)+365-1)/365);
    }
    return 0;
}