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 <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;
ll dp[100];

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

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

#define int long long

int dp[50];
int n;

void init() {
  dp[1] = dp[2] = dp[3] = 1;
  for (int i = 1; i <= 30; i++) {
    dp[i+1] += dp[i];
    dp[i+2] += dp[i];
    dp[i+3] += dp[i];
  }
}

signed main() {
  init();
  while (1) {
    cin >> n;
    if (n == 0) break;
    int day = (dp[n] + 3650 - 1) / 3650;
    cout << day << endl;
  }

  return 0;
}

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

int compare_int(const void* a, const void* b) { return *(int*) a - *(int*) b; }

//int n, dp[31];
//
//int func(int p) {
//	if (p == n) {
//		return 1;
//	}
//	int cnt = 0;
//	for (int i = p + 1; n >= i && 3 + p >= i; i++) {
//		if (dp[i] == -1) dp[i] = func(i);
//		cnt += dp[i];
//	}
//	return cnt;
//}
//
//int main() {
//	while (scanf("%d", &n) != EOF) {
//		if (n == 0) return 0;
//		memset(dp, -1, sizeof(dp));
//		printf("%d\n", ((func(0)+9) / 10 + 364) / 365);
//	}
//}

int main() {
	int n, dp[33] = {};
	dp[29] = 1;
	for (int i = 28; 0 <= i; i--) {
		dp[i] = dp[i + 1] + dp[i + 2] + dp[i+3];
	}

	while (1) {
		scanf("%d", &n);
		if (!n)return 0;
		printf("%d\n", ((dp[29 - n] + 9) / 10 + 364) / 365);
	}
	return 0;
}

/*

dp[i] = {dp[i+1]+dp[i+2]+dp[i+3] ????????????

*/

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

#define INF (1<<30)

int dp[40];


int main(){
	dp[0]=1;	dp[1]=2;	dp[2]=4;
	int n;

	for(int i=3;i<30;i++){
		dp[i]= dp[i-1] + dp[i-2] + dp[i-3];
	}
	while(cin>>n, n){
		cout<<(dp[n-1]+3649)/3650<<endl;

		
	}



	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int n;
	int a[33];

	cin >> n;
	a[0] = a[1] = 0;
	a[2] = 1;
	for(int i = 3;i < n+3;i++){
		a[i] = a[i-3] + a[i-1] + a[i-2];
	}
	int res = a[n+2]/10/365;
	if(a[n+2]% 3650 != 0)
		res ++;
	cout << res << endl;
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int steps[40];

int main() {
	int i;
	steps[1]=1;
	steps[2]=2;
	steps[3]=4;
	for(i=4;i<=30;i++){
		steps[i]=steps[i-1]+steps[i-2]+steps[i-3];
	}
	int n;
	while(n=in()){
		cout<<~-steps[n]/365/10+1<<endl;
	}
	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]-1)/3650;
		Q.push(A[n]);
		cin>>n;
	}
	while(Q.empty()==0){
		cout<<Q.front()<<endl;
		Q.pop();
	}
}

C++: #include <stdio.h>


int main(void)
{
	int a[1010];
	int b[1010];
	int t[1010];
	int ans[1010];
	int i=0;
	int j=0;
	int n=0;
	a[0] = 1;
	
	for(;;)
	{
		scanf("%d",&t[j]);
		if(t[j]==0)
		{
			
			break;
			
		}
		j++;
	}
	
	
	
	
	
	a[1]=1;
	a[2]=2;
	a[3]=4;
	
	for(i=4;i<1010;i++)
	{
		
		a[i]=a[i-1]+a[i-2]+a[i-3];
		ans[i]=a[i]/3650;
	}
	
	int k,unk;
	
	
	for(k=0;k<j;k++)
	{
		printf("%d\n",ans[t[k]]+1);
	}

}

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

int main(){
    int year;
    long long A[30];
    A[0]=1;
    A[1]=1;
    A[2]=2;
    int n;
    while(cin>>n && n!=0){
        for(int i=3;i<=n;++i){
            A[i]=A[i-1]+A[i-2]+A[i-3];
        }
        year=(A[n]/10)/365+1;
        cout<<year<<"\n";
    }
}

C++: #include<iostream>
#include<cmath>
using namespace std;
long long f(long long a,long long b) {
	return floor(a / b);
}
int main(){
	long long dp[30];
	dp[1] = 1; dp[2] = 2; dp[3] = 4;
	for (int i = 4; i <= 30; i++)
		dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
	int n;
	while (cin >> n){
		if (n == 0)return 0;
		cout << f(f(dp[n], 10), 365) + 1 << endl;
	}
}

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

int main() {
    int a[100]={0};
    a[0]=1;
    a[1]=1;
    a[2]=2;
    int n;
    int x;
    while(cin >>n){
    x=0;
    for(int i=3;i<n;i++){
    	a[i]=a[i-3]+a[i-2]+a[i-1];
    }
    x=a[n]/3650;
    x=x+1;
    cout << x;
    
    }
	return 0;
}

C++: #include <iostream>

using namespace std;

int cache[31] = {};

void init() {
    cache[1] = 1;
    cache[2] = 2;
    cache[3] = 4;
}

int count(int n) {
    if (cache[n] != 0) return cache[n];
    if (n <= 0) return 0;
    return count(n-1) + count(n-2) + count(n-3);
}

int main() {
    int n;
    init();
    while (cin >> n) {
        if (n == 0) break;
        int days = count(n);
        if (days % 3650 == 0) {
            cout << days / 3650 << endl;
        } else {
            cout << days / 3650 + 1 << endl;
        }
    }
    return 0;
}