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 <algorithm>
#include <iostream>

using namespace std;


int main(){
        
        int A[128], N;
        A[0] = 1;
        for(int i=1; i<=32; i++){
                A[i] = A[i-1];
                if(i>=1) A[i] += A[i-2];
                if(i>=2) A[i] += A[i-3];
        }
        while (cin >> N  && N)  cout << (((A[N] + 9)/ 10) + 364) / 365 << endl;

}

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

int main()
{
	int n;
	while (cin >> n,n)
	{
		int dp[n+3];
		memset(dp, 0, sizeof(dp));
		dp[0] = 1;
		for (int i=0; i<n; i++)
		{
			dp[i+1] += dp[i];
			dp[i+2] += dp[i];
			dp[i+3] += dp[i];
		}
		cout << dp[n]/3650 + (dp[n]%3650==0 ? 0 : 1) << endl;
	}
}

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

using namespace std;

long long dp(int a){
	if(a==0) return 1;
	else if(a==1) return 1;
	else if(a==2) return 2;
	else {
	return dp(a-3)+dp(a-2)+dp(a-1);
	}
}

int main() 
{
	int n;
	while(cin >> n , !(n==0))
	{
		long long day = dp(n);
		
		if(day%3650==0)
		cout << day/3650 << endl;
		else 
		cout <<day/3650 +1 << endl;
	}
	return 0 ;
}

C++: #include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	vector<ll> dp(31,0);
	dp[0]=1;
	for(int i=0;i<30;i++){
		dp[i+1] += dp[i];
		if(i+2<=30) dp[i+2] += dp[i];
		if(i+3<=30) dp[i+3] += dp[i];
	}

	while(true){
		ll N=in();
		if(!N) break;

		ll M=dp[N]/3650LL;
		if(dp[N]%3650LL) M++;
		out(M);
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll dp[35]; 
ll DP(ll m){
    dp[0] = 1, dp[1] = 2, dp[2] = 4;
    rep(i, 31){
        dp[i + 3] = dp[i] + dp[i + 1] + dp[i + 2];
    }
    return dp[m - 1];
}

int main(){ 
    while(true){
        int n; cin >> n;
        if(n == 0){
            break;
        }
        int ans = (DP(n) / 10) / 365 + 1;
        cout << ans << endl;
    }
}

C++: #include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<n; ++i)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define F first
#define S second
#define PB push_back
#define MP make_pair 
using namespace std;
typedef unsigned long ul;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef pair<int, int> pi;
const int INF = 100100100;
const unsigned int MOD = 1000000007;

bool is_prime(int n) { for (int i = 2; i*i <= n; ++i) { if (n % i == 0) return false; } return true; }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }

// メモ化再帰
int rec(int n) {
}

int main() {
    
    for(;;) {
        ll dp[35];
        REP(i, 35) dp[i] = INF;
        dp[0] = 1;
        dp[1] = 2;
        dp[2] = 4;
        
        int N; cin >> N;
        if(N == 0) break;
        
        for(int i = 3; i < N; ++i) {
            dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3]; 
        }
        
        cout << dp[N - 1]/10/365 + 1 << endl;
        
    }
}

C++: #include <iostream>
using namespace std;
int main(void){
    int i,n,a[31],year;
    a[1] = 1;
    a[2] = 2;
    a[3] = 4;
    for(i = 4; i < 31; i++){
        a[i] = a[i - 3] + a[i - 2] + a[i - 1];  //n[i]は1~30までの通り
    }
    while(true){
        cin >> n;
        if(n == 0){
            break;
        }
        else{
            year = a[n] / 3650;
            cout << year + 1 << endl;
        }
    }
}

C++: #include<iostream>


typedef struct k {
	int N;
	int day;
};

int main() {
	k a[30];
	int c,N[1000],c2;

	a[0].day = 1;
	a[1].day = 2;
	a[2].day = 3;

	for (c = 3; c < 30; ++c) {
		a[c].day = a[c - 1].day + a[c - 2].day + a[c - 3].day;
	}

	std::cin >> N[0];
	for (c = 1; N[c - 1] != 0;++c)
	{
		std::cin >> N[c];
	}
	c2 = c;
	for (c = 0; c < c2; ++c) {
		std::cout << N[c] << "\n";
	}

	






	
}

C++: #include<iostream>

long long int a[30];

int main(){
	int n;
	while (std::cin >> n){
		a[0] = 1, a[1] = 1, a[2] = 2;
		for (int i = 3; i <= n; ++i){
			a[i] = a[i - 1] + a[i - 2] + a[i - 3];
		}
		std::cout << (a[n]/3650)+1 << std::endl;
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

const int N = 30;
int dp[N+1];
int n;

int main() {
  while (1) {
    scanf("%d ", &n); 
    if (!n) break;
    memset(dp, 0, sizeof(dp));
    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]; 
    }
    int res = dp[n]/3650;
    if (dp[n]%3650) res++;
    printf("%d\n", res);
  }

	return 0;
}

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

int main()
{
	int n, p[31];
	p[0] = 1;
	p[1] = 1;
	p[2] = 2;
	for (int i = 3; i < 30; ++i)
	{
		p[i] = p[i-1] + p[i-2] + p[i-3];
	}
	while(1){
		int y;
		cin >> n;
		if(n == 0){
			break;
		}
		y = p[n] / 10 / 365;
		if(p[n]  / 10 % 365 != 0){
			y++;
		}
		cout << y << endl;
	}
	return 0;
}

C++: #include<iostream>

int dp[30];//段数ー１

int main(){
	int n;
	while(std::cin>>n,n){
		dp[0]=1;
		dp[1]=2;
		dp[2]=4;
		for(int i=3;i<n;i++){
			dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
		}
		if(dp[n-1]%365==0)std::cout<<dp[n-1]/3650<<std::endl;
		else std::cout<<dp[n-1]/3650+1<<std::endl;
		for(int i=3;i<n;i++)dp[i]=0;
	}
	return 0;
}