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 <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	while (true) {
		int n; cin >> n;
		if (n == 0)return 0;
		vector<int>dp(n+1);
		rep(i, n+1)dp[i] = INF;
		dp[0] = 1;
		if(1<=n)dp[1] = 2;
		if(2<=n)dp[2] = 4;
		FOR(i, 3, n + 1) {
			dp[i] = dp[i - 3] + dp[i - 2] + dp[i - 1];
		}
		dp[n-1] = (dp[n-1]+9)/10;
		cout << (dp[n-1]+364)/365 << endl;
	}

	return 0;
}

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

int main(){
	int n=1;
	int a = 0;
	int f = 0;
	int quest[10000] = { 1 };
	double ans[10000];
	int checkc = 0;
	int i = 4;
	double check[3] = { 1, 2, 4 };
	
	do{
		cin >> quest[a];
		a++;
	} while (quest[a-1] != 0);
	while (a > f+1){
		switch (quest[f]){
		case 1:
			ans[f] = 1;
			break;
		case 2:
			ans[f] = 2;
			break;
		case 3:
			ans[f] = 4;
			break;
		default:
			while (quest[f] >= i){
				ans[f] = check[0] + check[1] + check[2];
				i++;
				check[0] = check[1];
				check[1] = check[2];
				check[2] = ans[f];
			}
		}

		ans[f] = ans[f] / 3650;
		checkc = (int)(ans[f]);

		if (ans[f] > (double)(checkc)){
			checkc++;
		}
		if (ans[f] != 0){
			cout << checkc << endl;
		}
		else{
			cout << endl;
		}
		f++;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
    while(1)
    {
        int dp[31]={1,1,2,4};
        int n;
        cin>>n;if(!n)return 0;
        for(int i=4;i<=n;++i){
            dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
        }
        cout<<((dp[n]-1)/3650)+1<<endl;
    }
}

C++: #include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
	int dp[31];
	int n;
	while(scanf("%d",&n),n) {
		memset(dp,0,sizeof(dp));
		dp[0]=1;
		for(int i=1;i<=n;i++) {
			dp[i]+=(i-1)>=0?dp[i-1]:0;
			dp[i]+=(i-2)>=0?dp[i-2]:0;
			dp[i]+=(i-3)>=0?dp[i-3]:0;
		}
		printf("%d\n",(int)ceil(ceil(dp[n]/10.0)/365.0));
	}
}

C++: #include <algorithm>
#include <iostream>
using namespace	std;
int a[128]={1,1,2},n;
int main()
{
  for(int i=3;i<31;i++)
    a[i]=a[i-1]+a[i-2]+a[i-3];
  while(cin >> n, n)
    cout << a[n]/10/365+1 << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007; 
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;}

int main(){
  vll dp(31, 0);
  dp.at(0) = 1;
  rep(i, 0, 30){
    rep(j, i + 1, min(30, i + 3) + 1){
      dp.at(j) += dp.at(i);
    }
  }
  
  while(true){
    ll n;
    cin >> n;
    if(n == 0) break;
    cout << (dp.at(n) + 3649) / 3650 << endl; 
  }
}

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

int calc(int x){
    if(x < 0) return 0;
    if(x == 0) return 1;
    return calc(x - 1) + calc(x - 2) + calc(x - 3);
}

int main(){
    int n;
    while(cin >> n){
        cout << (calc(n) + 3649) / 3650 << endl;
    }
}

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

vector<long long> step_pattern(30,0);

int steps(int n){
    int s;
    if(step_pattern.at(n-1)!=0){
        s=step_pattern.at(n-1);
    }else{
        s=steps(n-1)+steps(n-2)+steps(n-3);
        step_pattern.at(n-1)=s;
    }
    return s;
}

int main(){
    step_pattern.at(0)=1;
    step_pattern.at(1)=2;
    step_pattern.at(2)=4;
    int n;
    vector<int> answers;
    while(cin >> n && n!=0){
        int years=steps(n)/3650;
        if(steps(n)%3650!=0){
            years++;
        }
        answers.push_back(years);
    }
    for(int i=0;i<answers.size();i++){
        cout << answers.at(i) << endl;
    }
    return 0;
}

C++: #include <iostream>
int main(void){
	long long int dp[30];
	dp[0]=1;
	dp[1]=2;
	dp[2]=4;
	for(int i=3;i<30;i++){
		dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
	}
	int n;
	while(1){
		std::cin>>n;
		if(n==0){
			break;
		}else {
			std::cout<<dp[n-1]/3650+1<<std::endl;
		}
	}
	return 0;
}

C++: #include <algorithm>
#include <iostream>
using namespace std;
int n;
int main() {
  while (cin >> n && n>0) {
    int A[n];
    A[0] = 1;
    for (int i=1; i<=n; ++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]+9)/10+364)/365 << endl; 
  }
}

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

const int kMaxJumpStep = 3;

int dp(const int N){
	std::vector<int> step(N+1);
	step[0] = 1;

	for (int i = 0; i < N; i++){
		for (int j = i + 1; j <= i + kMaxJumpStep; j++){
			if (j > N) break;
			step[j] += step[i];
		}
	}

	return step[N];
}

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

	while (1){
		int n;
		std::cin >> n;
		if (n == 0) break;
		std::cout << dp(n)/3650 + 1 << std::endl;
	}

	return 0;
}