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>

#define MAX 31

int main(){
  int dp[MAX] = {1,1,2};

  for(int i = 3 ; i < MAX ; i++){
    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;

int cnt;
int dp[100][100];

void rec(int left){
    if (left < 0){
        return;
    }
    if (left == 0){
        cnt++;
        return;
    }

    rec(left-1);
    rec(left-2);
    rec(left-3);

}

int main(int argc, char const *argv[]){
    int n;

    while (cin>>n, n){
        cnt = 0;
        int ans = 0;
        rec(n);
        ans = cnt / 3650;
        cout<<ans+1<<endl;       
    }

    return 0;
}

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

int s[30];
int n;

int main() {
  
  while(1) {
    cin >> n;
    if(!n)break;
    
    s[0] = 1;
    s[1] = 2;
    s[2] = 4;
    
    for(int i=3;i<n;i++) {
      s[i] = s[i-1]+s[i-2]+s[i-3];
    }
    
    cout << (s[n-1]/3650) << endl;
    
  }
  return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

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

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

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

C++: #include<iostream>
#include<algorithm>
#include<utility>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define P pair<int, int>

using namespace std;


int main(){
	int n;
	int ways[31];
	ways[0] = 1, ways[1] = 1, ways[2] = 2;
	loop(i,3,31){
		ways[i] = ways[i - 1] + ways[i - 2] + ways[i - 3];		
	}

	while (1){
		cin >> n;
		if (n == 0){
			break;
		}
		int ans;
		ans = ways[n] / 3650;
		if (ways[n] % 3650){
			ans++;
		}


		cout << ans << endl;
	}

}

C++: #define _CRT_SECURE_NO_WARNINGS

#include<cstdio>
#include<algorithm>

#define N_MAX 30

int main(){
	while (1){
		int n, dp[N_MAX + 1];
		scanf("%d", &n);
		if (n == 0)
			break;
		std::fill(dp, dp + n + 1, 0);
		dp[0] = 1;
		dp[1] = 1;
		dp[2] = 2;
		for (int i = 3; i <= n; ++i){
			for (int j = 1; j <= 3; ++j){
				if (j <= i){
					dp[i] += dp[i - j];
				}
			}
		}
		int day = (dp[n] % 10 == 0) ? dp[n] / 10 : dp[n] / 10 + 1;
		int ans = (day % 365 == 0) ? day / 365 : day / 365 + 1;
		printf("%d",ans);
	}
	return 0;
}

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

int main(){
	int n,A[40];
	queue<int> Q;
	A[0]=1;
	cin>>n;
	while(n !=0){
		for(int i=1;i<n+1;++i){
			A[i]=A[i-1];
			if(i>1){
				A[i]+=A[i-2];
			}
			if(i>2){
				A[i]+=A[i-3];
			}
		}
		A[n]=1+(A[n]/3651);
		Q.push(A[n]);
		cin>>n;
	}
	while(Q.empty()==0){
		cout<<Q.front()<<endl;
		Q.pop();
	}
}

C++: #include <iostream>

using namespace std;

int cases[31];

int main() {
    cases[1] = 1;
    cases[2] = 2;
    cases[3] = 4;
    for (int n = 4; n < 31; n++)
        cases[n] = cases[n-1] + cases[n-2] + cases[n-3];

    int N = 0;
    while (cin>>N && N != 0) {
        cout<<((cases[N]+9)/10+364)/365<<endl;
    }
}

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

#define int				long long
#define FOR( i, m, n )	for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )		FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )		(a).begin(), (a).end()
#define MP				make_pair

typedef pair<int, int> P;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

int dp[31];

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

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

}

C++: #include<stdio.h>
#include<math.h>

int main(){
	long long dan[32];
	int n,i;
	
	dan[0]=0;
	dan[1]=1;
	dan[2]=2;
	dan[3]=4;
	for(i=4;i<32;i++){
		dan[i]=dan[i-1]+dan[i-2]+dan[i-3];
	}
	for(i=0;i<32;i++){
		dan[i]=((dan[i]+9)/10+364)/365;
	}
	while(0<=scanf("%d",&n)){
		if(n==0)break;
		printf("%lld\n",dan[n]);
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    unsigned long dp[31] = { 1, 1, 2 };
    for( int i=3; i<31; ++i )
        dp[i] = dp[i-3] + dp[i-2] + dp[i-1];

    int n;
    while( cin >> n ) {
        if ( n == 0 )
            break;
        cout << dp[n] / 3650 + ( dp[n] % 3650 != 0 ) << endl;
    }
}

C++: #include <iostream>
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
  
VI memo;
int f(int n){
    if(n<0)
        return 0;
    if(n==0)
        return 1;
    if ( memo[n]!= -1 )
        return memo[n];
    return f(n-1)+f(n-2)+f(n-3);
}
 
int main(){
    int n;
    memo.resize(31,-1);
    while(1){
        cin >> n;
        if(n==0)
            break;
        int num=f(n);
        cout <<num/10/365+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 dump(x)  cerr << #x << " = " << (x) << endl
#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 dp[50];
    rep(i,50)dp[i]=0;
    dp[0]=1;
    rep(i,40){
        dp[i+1]+=dp[i];
        dp[i+2]+=dp[i];
        dp[i+3]+=dp[i];
    }
    
    
    int n;
    while(cin>>n){
        if(n==0)break;
        int num = (int)((dp[n]-1)/3650)+1;
        cout<<num<<endl;
    }

}