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 <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repn(i,n,m) for(int i=n;i<m;i++)
#define repn1(i,n,m) for(int i=n;i<=m;i++)
using namespace std;

int main(){

	int dp[100] = {0};
	int n,m;
	
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;

	repn(i, 4, 35) dp[i] = dp[i-1] + dp[i-2] + dp[i-3];

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

	return 0;
}

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


int main(){
	int dp[31]={0};
	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];
	}
	int n;
	while(cin>>n&&n){
		cout<<(dp[n]+3649)/3650<<endl;
	}
	return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll dp[50]; // dp[i]: i段目まで上る方法の数

void init() {
   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];
   }
}

int main() {
   init();
   while (1) {
      int n;
      cin >> n;
      if (!n) break;
      ll day = max(1LL, dp[n] / 10);
      // debug(day)
      cout << day / 365 + (day%365 != 0) << endl;
      // line()
   }

   return 0;
}

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

int main(){
	int n;
	int step[35];

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

	for(int i=1;i<30;i++){
		step[i+3]=step[i+2]+step[i+1]+step[i];
	}
	while(cin>>n){
		if(n==0)return 0;
		if(step[n]%3650==0){
			cout<<step[n]/3650<<endl;
		}else{
			cout<<step[n]/3650+1<<endl;	
		}
	}
	return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;

int dp[31];

int main() {
	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(scanf("%d", &N), N) printf("%d\n", dp[N] / 3650 + 1);
	return 0;
}

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

long long memo[41];

long long solve(int rem){
  if(rem == 0) {
    return 1;
  }
  if(memo[rem] > 0) return memo[rem];

  long long sum = 0;
  for(int i=1;i<=3;i++){
    if(rem >= i) sum += solve(rem-i);
  }
  return (memo[rem] = sum);
}

int main(void){
  int n;

  while(cin>>n && n){
    long long day = solve(n);
    if(day % 3650 == 0) cout<<day / 3650<<endl;
    else cout<<day / 3650 + 1 << endl;
  }

  return 0;
}

C++: #include "bits/stdc++.h"

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main(){
    int n;
    ll dp[40];
    while(cin>>n){
        if(n==0)break;
        
        rep(i,40)dp[i] = 0;
        dp[0]=1;
        rep(i,35){
            dp[i+1]+=dp[i];
            dp[i+2]+=dp[i];
            dp[i+3]+=dp[i];
        }
        ll ans = dp[n];
        ans = ceil(ans/3650.0);
        cout<<ans<<endl;
    }
}

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

using namespace std;

int main()
{
    int N;
    while (cin >> N, N)
    {
        int dp[30] = {0};

        dp[0] = 1; dp[1] = 1; dp[2] = 2;

        for(int i = 3; i <= N; i++)
            dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];

        cout << 1 + dp[N] / 3650 << endl; 
    }
}

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

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();}
template<class T> inline T sqr(T x) {return x*x;}

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 pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int rec(int n){
	if(n==0) return 1;
	int res=0;
	if(n-1>=0) res+=rec(n-1);
	if(n-2>=0) res+=rec(n-2);
	if(n-3>=0) res+=rec(n-3);
	return res;
}

int main(void){
	int n;
	while(cin >> n,n){
		cout << rec(n)/3650+1 << endl;
	}
	return 0;
}

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

// #define int long long

/* short */
#define pb push_back
#define print(Target) cout << Target << '\n'

/* REPmacro */
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

/* const */
const int INF = INT_MAX;

int dp[31];

int shinobu(int n)
{
  if (dp[n] != -1){
    return (dp[n]);
  }
  if (n == 1) return (1);
  if (n == 2) return (2);
  if (n == 3) return (4);
  return (shinobu(n - 1) + shinobu(n - 2) + shinobu(n - 3));
}

signed main()
{
  ios::sync_with_stdio(false);
  int n;

  while (cin >> n, n){
    fill(dp, dp + 31, -1);
    print(shinobu(n) / 3650 + 1);
  }
  return (0);
}

C++: #include <iostream>
using namespace std;
int num(int n);
int main(){
  int n;cin >> n;
  cout << num(n)/3650+1 <<endl;
}

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

C++: #include<iostream>

using namespace std;

int func(int x);

int main() {
	int x;
	while (true) {
		cin >> x;
		if (x == 0) { break; }
		cout << func(x) / 3650 + 1 << endl;
	}
	
	return 0;
}

int func(int x) {
	if (x == 1) {
		return 1;
	}
	else if (x == 2) {
		return 2;
	}
	else if (x == 3) {
		return 4;
	}
	else {
		return func(x - 1) + func(x - 2) + func(x - 3);
	}
}