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<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    using namespace std;
    using Graph = vector<vector<int>>;

    #define INF 10000000
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    const int dx[4] = {1,0,-1,0};
    const int dy[4] = {0,1,0,-1};
    
    
    
    int main(){
      int n;
      int year = 3650;
      while(cin>>n){
      if(n==0)break;
      long long dp[n];

      

      int j=0;
      dp[0] = 1;
      dp[1] = 1;
      dp[2] = 2;
      REP(i,3,n){
        dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
      }
      int res;
      if(dp[n]%year)res = dp[n]/year+1;
      else res = dp[n]/year;
      cout << res <<endl;
      }
    }

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;
        cout << (f(n) / 3650)+1 << endl;
    }
}

C++: #include<iostream>

using namespace std;

int func(int x);

int main() {
	int x;
	while (cin >> x) {
		cin >> x;
		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);
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

vector<LL> memo;

LL solve(int n) {
	if (n < 0) return 0;
	if (memo[n] != -1) return memo[n];
	if (n == 0) return memo[n] = 1;

	return memo[n] = solve(n - 1) + solve(n - 2) + solve(n - 3);
}

int main(void) {
	memo.resize(31, -1);
	int N;
	
	while (cin >> N, N) {
		cout << (solve(N) / 10 + 365) / 365 << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    vector<int> dp(35);
    dp[0] = 1;
    for (int i = 0; i < 30; ++i) {
        for (int j = 1; j <= 3; ++j) {
            dp[i+j] += dp[i];
        }
    }
    int n;
    while(cin >> n, n){
        cout << (dp[n]+3649)/3650 << "\n";
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
 
int num(int n);
 
int main(){
  int n;
  cin>>n;
  cout << (num(n)+3649)/3650<<endl;
}
 
int num(int n){
    switch (n)
    {
        case 1: return 1;
        case 2:  return 2;
        case 3:  return 4;
    }
  return num(n-1)+num(n-2)+num(n-3);
}

C++: #define _USE_MATH_DEFINES
#define MAX_N 1000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 1e-8;

ll dp[100][100];

ll nCr(int n,int r){
	return dp[n][r] != -1 ? dp[n][r] : 
		dp[n][r] = (r==0|| n==r) ? 1 : nCr(n-1,r) + nCr(n-1,r-1);
}

int main(){
	memset(dp,-1,sizeof(dp));

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		ll res=0;

		for(int i=0;i<=n;i++){
			for(int j=0;j<=n;j++){
				for(int k=0;k<=n;k++){
					if(i+2*j+3*k == n){
						res += nCr(i+j+k,i) * nCr((i+j+k)-i,j) * nCr((i+j+k)-i-j,k);
					}
				}
			}
		}

		printf("%lld\n",res/3650 + 1);
	}
}

C++: #include <iostream>
#include <vector>
#include <string.h>

#define pb push_back

using namespace std;

int dp[35];

int main(void)
{
	int n;
	int maxx=0;
	vector<int> v;
	int year;
	int i1;

	while(1){
		cin>>n;
		if(n==0) break;
		v.pb(n);
		maxx=max(maxx,n);
	}

	dp[0]=1;
	dp[1]=1;
	dp[2]=2;
	for(i1=3;i1<=maxx;i1++){
		dp[i1]=dp[i1-1]+dp[i1-2]+dp[i1-3];
	}

	for(i1=0;i1<v.size();i1++){
		if(dp[v[i1]]%10==0) {
			year=dp[v[i1]]/10;
		}
		else {
			year=dp[v[i1]]/10+1;
		}

		if(year%365==0){
			year=year/365;
		}
		else {
			year=year/365+1;
		}
		cout<<year<<endl;
	}

	return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()

using namespace std;

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

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int n;
int memo[31];

int solve(int cnt){
	if(memo[cnt] != -1) return memo[cnt];
	if(cnt >= n) return memo[cnt] = cnt == n;
	int res1 = memo[cnt] = solve(cnt + 1);
	int res2 = memo[cnt] = solve(cnt + 2);
	int res3 = memo[cnt] = solve(cnt + 3);
	return memo[cnt] = res1 + res2 + res3;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	while(1){
		rep(i,31)
			memo[i] = -1;
		cin >> n;
		if(n == 0) break;
		int ans = solve(0);
		cout << (ans / 10 / 365) + 1 << endl;
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int dp[31];
	int i;
	while(1){
		cin>>n;
		if(n==0)	break;
		for(i=1;i<=n;i++){
			dp[i]=0;
		}
		dp[1]=1;
		dp[2]=1;
		dp[3]=1;
		for(i=1;i<=n;i++){
			for(int j=1;j<=3;j++){
				dp[i+j]+=dp[i];
			}
		}
		if(dp[n]<3650){
			cout<<"1"<<endl;
		}
		else{
			int ans=dp[n]/3650;
			if(dp[n]%3650!=0){
				ans++;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}