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++: // compile in C++11. use -std=c++11.
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// these require C++11
#include <unordered_set>
#include <unordered_map>
#include <random>

using namespace std;

#define int long long

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x) 
#endif

typedef complex<double> point;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n;
	unsigned long long a[40];
	a[0]=1;
	a[1]=2;
	a[2]=4;
	for(int i=3;i<40;i++){
		a[i]=a[i-3]+a[i-2]+a[i-1];
	}
	while(cin>>n){
		if(n==0) break;
		cout<<(int)ceil((double)a[n-1]/3650.0)<<endl;
	}
    return 0;
}

C++: #include <iostream>
using namespace std;
int A[33], N;
int main(){
  while (cin >> N && N){
    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];
      }
    }
    cout << A[N] / 3650 + 1 << endl;
  }
}

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

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

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

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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define pf push_front
#define pb push_back
#define FST first
#define SEC second
#define sz(obj) ((int)(obj).size())

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  
  while (cin >> n, n){
    int dp[35] = {0};
    int cnt = 0, ans;

    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];
    }
    ans = dp[n] / 3650;
    if (dp[n] % 3650) ans += 1;
    cout << ans << endl;
  }
}

C++: #include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>

using namespace std;

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

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  int m[31] = {1,1,2};
  
  loop(i,3,31){
    m[i] = m[i-1] + m[i-2] + m[i-3];
  }
  while(cin>>n,n){
    cout<<m[n] / 3650 + 1 <<endl;
  }
}

C++: #include<iostream>
using namespace std;
int main() {
	int a,dp[44];
	while (1) {
		cin >> a;
		if (a == 0) {
			goto a;
		}
		a = a + 1;
		for (int i = 0; i <= 43; i++) {
			dp[i] = 0;
		}
		dp[1] = 1;
		for (int i = 1; i <= a; i++) {
			if (i >= 4) {
				for (int m = i - 3; m < i; m++) {
					dp[i] = dp[i] + dp[m];
				}
			}
			if (i == 3) {
				for (int m = i - 2; m < i; m++) {
					dp[i] = dp[i] + dp[m];
				}
			}
			if (i == 2) {
				for (int m = i - 1; m < i; m++) {
					dp[i] = dp[i] + dp[m];
				}
			}
		}
		int ans;
		ans = dp[a] / 3650;;
		if (dp[a] % 365 >= 0) {
			ans = ans + 1;
		}
		cout << ans << endl;
	}
a:;
}

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[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];
      // 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 <cstdio>
#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 <fstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int memo[31];
int f(int n){
  if(n<0) return 0;
  if(n<2) return 1;
  if(memo[n]!=-1) return memo[n];
  return (memo[n]=f(n-1)+f(n-2)+f(n-3));
}

int main(void){
  memset(memo,-1,sizeof(memo));
  int n;
  while(cin>>n){
    if(n==0)break;
    cout<<f(n)/3650+1<<endl;
  }
  return 0;
}