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++: #define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>
#include<bitset>
#include<stack>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> lltpl;

int dy8[8] = { 2,2,-2,-2,1,1,-1,-1 };
int dx8[8] = { 1,-1,1,-1,2,-2,2,-2 };
int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };


/******************************************************************************************/


const int IINF = 1e9 + 7;
const ll LINF = LLONG_MAX;
constexpr ll MOD = 1e9 + 7;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

// vector
template <typename T>
istream& operator>>(istream & is, vector<T> & vec) { for (T& x : vec) is >> x; return is; }
// pair
template <typename T, typename U>ostream& operator<<(ostream & os, pair<T, U> & pair_var) { os << "(" << pair_var.first << ", " << pair_var.second << ")"; return os; }
// vector
template <typename T>ostream& operator<<(ostream & os, const vector<T> & vec) { os << "{";	for (int i = 0; i < vec.size(); i++) { os << vec[i] << (i + 1 == vec.size() ? "" : ", "); }os << "}"; return os; }
// map
template <typename T, typename U>ostream& operator<<(ostream & os, map<T, U> & map_var) { os << "{";	repi(itr, map_var) { os << *itr; itr++; if (itr != map_var.end()) os << ", "; itr--; }os << "}"; return os; }
// set
template <typename T>ostream& operator<<(ostream & os, set<T> & set_var) { os << "{"; repi(itr, set_var) { os << *itr; itr++; if (itr != set_var.end()) os << ", "; itr--; }os << "}"; return os; }


int dp[50];

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;

	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 (cin >> n, n) {

		cout << ceil((dp[n]/(double)10) / (double)365) << endl;

	}





	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; --i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;

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;
//const long long mod = 1e9+7;

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

ll dp[35];
ll a[35];

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

  int i = 0;
  while(1){
      int n; cin >> n;
      a[i] = n;
      if(n==0) break;
      i++;
  }
  int N = i;

  rep(i,N){
      rep(k,35) dp[k] = 0;
      dp[0] = 1;
      rep(j,a[i]){
          dp[j+1] += dp[j];
          dp[j+2] += dp[j];
          dp[j+3] += dp[j];
      }
      ll tmp = (dp[a[i]]/10);
      if(tmp%365==0 && tmp!=0) cout << tmp/365 << endl;
      else cout << tmp/365 + 1 << endl;
  }


  return 0;
}

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

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

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

using namespace std;

long long dp[33];

int main() {
  int n;
  
  while( cin >> n, n ) {
    fill(dp, dp+32, 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 << dp[n]/3650+1 << endl;
  }
  
  return 0;
}

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

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 main() {
	int a[30];
	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];
	while ( int n; cin >> n ) 
		cout << a[n] << endl;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<utility>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define all(v) v.begin(),v.end()
using namespace std;

const double eps = 1e-8;
const double INF = 1e12;

typedef pair<long,long> P;
typedef double Real;
typedef complex<Real> Point;
typedef vector<Point> G;

double cross(const Point& a,const Point& b){//calculate ad-bc(vector product)
	return imag(conj(a)*b);
}

struct L:public vector<Point>{//line data
	L(const Point &a,const Point &b){
		push_back(a);
		push_back(b);
	}
};

int n;
int dp[31];

long long func(int i){//i??????????§???????n??????????????????????????°???????????¢??°
	long long res;
	if(dp[i]!=-1)return dp[i];
	if(i==n)return 1;
	else if(i==n-1)res=func(i+1);
	else if(i==n-2)res=func(i+1)+func(i+2);
	else res=func(i+1)+func(i+2)+func(i+3);
	return dp[i]=res;
}

int main(){
	while(cin>>n){
		if(!n)break;
		memset(dp,-1,sizeof(dp));
		unsigned long long sum=func(0);
		bool check=false;
		if(sum%10)check=true;
		sum/=10;
		if(check)sum++;
		long long ans=sum/365;
		if(sum%365)ans++;
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{

  int step_num;
  int dp[31];

  fill(dp,dp + 31,0);

  0[dp] = 1;

  for(int i = 1; i <= 30; ++i)
    {
      for(int j = 1; j <= 3; ++j)
        {

          if( i - j >= 0)   dp[i] = dp[i] + dp[i - j];

        }
    }

  while(cin >> step_num && step_num != 0) { cout << dp[step_num]/10/365 + 1<< endl; }

  return 0;

}