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 <vector>
using namespace std;

int main() {
	int n;
	vector<int> a(31);
	a[1] = 1;
	a[2] = 2;
	a[3] = 4;
	for (int i = 4; i < 31; ++i) a[i] = a[i - 3] + a[i - 2] + a[i - 1];
	while (cin >> n, n) cout << (364 + (9 + a[n]) / 10) / 365 << endl;
}

C++: #include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
signed main() {
  int N;
  while (cin>>N, N!=0) {
    if (N < 3) {
      cout << 1 << endl;
      continue;
    }
    int dp[N];
    dp[0] = 1;
    dp[1] = dp[0]+1;
    dp[2] = dp[1]+dp[0]+1; 
    for (int i = 3; i < N; i++) {
      dp[i] = dp[i-3] + dp[i-2] + dp[i-1];
    }
    cout << ceil((dp[N-1]/10.0)/365.0) << endl;
  }  
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <queue>

using namespace std;

int main(){
    while(true){
        int n; cin >> n;
        if(!n) break;
        vector<long long> dp(n+1);
        dp[0]=1;
        for(int i=1; i<=n; ++i){
            if(i-3>=0) dp[i]+=dp[i-3];
            if(i-2>=0) dp[i]+=dp[i-2];
            if(i-1>=0) dp[i]+=dp[i-1];
        }
        long long tmp=(dp[n]+10-1)/10;
        cout << (tmp+365-1)/365 << endl;
    }
    return 0;
}

C++: #include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
int main(){
	int N;
	while(cin>>N){
		if(N==0)break;
		int dp[33]={};
		dp[0]=1;
		for(int i=0;i<N;i++){
			for(int j=1;j<=3;j++){
				dp[i+j]+=dp[i];
			}
		}
		if(dp[N-1]%365==0){
			cout<<dp[N]/3650<<endl;
		}
		else cout<<(dp[N]/3650)+1<<endl;
	}
	return 0;
}

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

int num(int n);

int main()
{
  int n;
  cout << num(cin>>n) <<endl;
}

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

C++: #include <iostream>
using namespace std;
#define rep(i,x,to) for(int i=x;i<to;i++)

int main() {
	int n,dp[30]={1,1,2};
	while(1){
		cin >> n;
		if(n==0) break;
		rep(i,3,30){
			dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
		}
		cout << dp[n]/3650+(dp[n]%3650!=0) << endl;
	}
	return 0;
}

C++:  #include <iostream>
 #include <vector>
 #include <map>
 #include <string>
 #include <algorithm>
 using namespace std;

 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;
}

 typedef long long ll;
 const long long INF = 1LL << 60;



 int main()
 {
    int n;
    
    while(1)
    {
        cin >> n;
        if(n == 0) break;

        vector<ll> dp(n+1, 0);
        dp.at(0) = 1;

        for(int i = 1; i < n+1; i++)
        {
            dp.at(i) += (ll)(dp.at(i-1));
            if(i > 1) dp.at(i) += (ll)(dp.at(i-2));
            if(i > 2) dp.at(i) += (ll)(dp.at(i-3));
        }

        dp.at(n) = (dp.at(n) + 10 - 1) / 10;
        ll ans = (ll)(dp.at(n) + 365 - 1) / 365;
        cout << ans << endl;
    }



    return 0;
 }

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

int dp[31];

int main() {
    dp[0] = 1;
    for (int i=1; i<31; ++i) {
        int sum = 0;
        for (int j=i-1; j>=i-3 && j>=0; --j) {
            sum += dp[j];
        }
        dp[i] = sum;
    }
    int n;
    while (cin >> n, n) {
        if (dp[n] % 3650 == 0) {
            cout << dp[n] / 3650 << endl;
        } else {
            cout << dp[n] / 3650 + 1 << endl;
        }
    }
    return 0;
}

C++: #include<iostream>

struct Memo
{

	int count;
	bool flag;

	Memo()
	{

		count = 0;
		flag = false;

	}

};

using namespace std;

Memo memo[31][4];

int ProgressNumberOfYears(int step_num,int step_length)
{

	int kind_count = 0;

	if(memo[step_num][step_length].flag && step_length != 0) return memo[step_num][step_length].count;
	else if(step_num == 0) return 1;
	else if(step_num < 0) return 0;

	for(int i = 1; i < 4; ++i)	kind_count += ProgressNumberOfYears(step_num - i,i);

	Memo temp;

	temp.count = kind_count;
	temp.flag = true;

	memo[step_num][step_length] = temp;

	return kind_count;

}

int main()
{

	int step_num;

	while(cin >> step_num && step_num != 0) cout << ProgressNumberOfYears(step_num,0) / 10 / 365 + 1 << endl;

	return 0;

}

C++: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n,step[35] = {0};

    step[0] = 1;
    rep(i,30){
        step[i + 1]+=step[i];
        step[i + 2]+=step[i];
        step[i + 3]+=step[i];
    }

    while(cin >> n, n){
        step[n]+= 3649;
        cout << step[n] / 3650 << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

int main() {
  int table[31];
  table[0] = 1;
  table[1] = 1;
  table[2] = 2;
  for (int i=3; i<=30; ++i) {
    table[i] = table[i-1] + table[i-2] + table[i-3];
  }
  int n;
  while(cin >> n,n) {
    cout << (table[n]-1)/10/365+1 << endl;
  }
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;

    while(cin >> n, n){
        int floor[35] = {0};
        floor[0] = 1;
        range(i, 1, n+1){
            if(i >= 1) floor[i] += floor[i - 1];
            if(i >= 2) floor[i] += floor[i - 2];
            if(i >= 3) floor[i] += floor[i - 3];
        }
        cout << floor[n] / 3650 + 1 << endl;
    }

}

C++: #include <iostream>
using namespace std;
long long solve(int now){
    if(now==0) return 1;
    if(now<0)  return 0;
    long long res=solve(now-1)+solve(now-2)+solve(now-3);
    return res;
}
int main(void){
    int n;
    cin>>n;
    solve(n);
    cout<<solve(n)/3650+1<<endl;
    // Your code here!
    
}

C++: #include <iostream>
#include <vector>
#include<queue>
using namespace std;
#define loop(i,n) for (int i = 0; i < n; i++)
int main()
{
	int n;
	cin >> n;
	vector<long long int> dp(n + 1, 0);
	dp[0] = 1;
	loop(i, n)
	{
		dp[i + 1] += dp[i];
		if (i + 2 < n + 1)dp[i + 2] += dp[i];
		if (i + 3 < +n + 1)dp[i + 3] += dp[i];
	}
	cout << (((dp[n] + 9) / 10) + 364) / 365 << endl;
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
    int a[31];
    int n;
    while(cin>>n&&n){
        a[1]=1;
        a[2]=2;
        a[3]=4;
        for(int i=4;i<=n;i++){
            a[i]=a[i-1]+a[i-2]+a[i-3];
        }
        cout<<((a[n]-1)/3650)+1<<endl;
    }
}