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<cstring>
using namespace std;
int main()
{
	int dp[31];
	dp[0]=1;
	for(int i = 1; i < 31; ++i)
	{
		dp[i]=dp[i-1];
		if(2<=i) dp[i]+=dp[i-2];
		if(3<=i) dp[i]+=dp[i-3];
	}

	int n;
	while(cin>>n,n) 
	{
		int comb=dp[n];
		int ans=0;
		while(comb>0) 
		{
			comb-=3650;
			ans++;
		}
		cout<<ans<<endl;
	}
  return 0;
}

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

int main()
{
	int n;
	int day[100] = {0};
	
	day[0] = 0;
	day[1] = day[2] = 1;
	
	for(int i = 3; i < 50; i++){
		day[i] = day[i-1] + day[i-2] + day[i-3];
	}
	
	while(scanf("%d", &n), n != 0){
		int year;
		
		year = day[n+1] / 10 / 365;
		
		printf("%d\n", year + 1);
	}
	return(0);
}

C++: #include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

long dp[31];

int main(){
  fill(dp, dp+31, 0);
  dp[0]=1;
  for(int i=1; i<=30; i++){
    for(int j=1; j<=3; j++){
      if(i-j>=0) dp[i] += dp[i-j];
    }
  }
  int n;
  while(cin>>n, n){
    long res = (((dp[n]+9)/10)+364)/365;
    cout<<res<<endl;
  }

  return 0;
}

C++: #include<stdio.h>
int n;
int dp[30];
int main(){
    dp[0]=1;
    dp[1]=2;
    dp[2]=4;
    for(int i=3;i<30;i++){
        dp[i]=dp[i-3]+dp[i-2]+dp[i-1];
    }
    while(1){
        scanf("%d",&n);
        if(n==0) return 0;
        printf("%d\n",(int)((dp[n-1]+9)/10+364)/365);
    }
}

C++: #include <iostream>
using namespace std;
int main(void){
   // Your code here!
   int i,n,t,k,c,b;
   while(1){
       cin >> n;
       if (n==0) break;
       int a[35]={0};
       a[0]={1};
       a[1]={1};
       a[2]={2};
       for(i=3;i<=n;i++){
           a[i]=a[i-3]+a[i-2]+a[i-1];
       }
       c=a[n]/10;
       b=a[n]%10;
       if(b != 0){
           c=c+1;
       }
       k= c / 365;
       t= c % 365;
       if(t != 0){
           k=k+1;
       }
       cout << k;
       cout << endl;
}
}

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

long long dp[35];
int main()
{
	for (auto &x : dp) x = 0;
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	for (int i = 3; i < 31; i++){
		dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
	}
	while (1){
		int n;
		cin >> n;
		if (n == 0) return 0;
		cout << dp[n] / 3650 + (dp[n]%3650 ? 1 : 0) << endl;
	}
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;

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

  ll dp[40] = {};
  dp[0] = 1;
  dp[1] = 2;
  dp[2] = 4;
  for(int i = 3; i < 40; i++) {
    dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
  }

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

    ll day = (dp[n-1]+10-1)/10;
    cout << (day+365-1)/365 << '\n';
  }
  return 0;
}

C++: #include <iostream>


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

const int kMaxJumpStep = 3;

int dp(const int N){
	std::vector<int> step(N+2);
	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;
}

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

int main() {
    int n;
    long long dp[35] = {0};

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

    while (1) {
        cin >> n;
        if (n - 1 == -1) break;

        long long ans = 0;
        ans = dp[n - 1] / 3650;
        if (dp[n - 1] % 3650) ans++;
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

struct Memo
{

  int count;
  bool flag;

  Memo()
  {
    count = 0;
    flag = false;
  }

};

Memo memo[31][4];

int ProgressNumberOfYears(int step_num, int step_kind)
{

  int kind_count = 0;

  if(step_num == 0) return 1;
  else if(memo[step_num][step_kind].count) return memo[step_num][step_kind].count;

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

  if(step_num - 3 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 3,3);
  if(step_num - 2 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 2,2);
  if(step_num - 1 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 1,1);

  memo[step_num][step_kind].count = kind_count;

  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>

using namespace std;

int n;
int dp[33];

int solve(int now){

    if(dp[now] != -1) return dp[now];

    if(now == n) return 1;
    else if(now > n) return 0;
    else {
        return dp[now] = solve(now + 1) + solve(now + 2) + solve(now + 3);
    }

}

int main(){

    while(cin >> n, n){

        memset(dp, -1, sizeof(dp));

        int pattern = (solve(0) - 1) / 3650 + 1;

        cout << pattern << endl;

    }

}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int dp[31] = { 1,1,2,4 };

int a(int n) {
	if (dp[n])return dp[n];
	dp[n] += dp[n - 1] ? dp[n - 1] : a(n - 1);
	dp[n] += dp[n - 2] ? dp[n - 2] : a(n - 2);
	dp[n] += dp[n - 3] ? dp[n - 3] : a(n - 3);
	return dp[n];
}

int main() {
	for (int n; cin >> n&&n;)
		cout << ceil((double)a(n) / (365 * 10)) << endl;
	return 0;
}

C++: #include <algorithm>
#include <iostream>
using namespace std;
int A[128], N;
int main(){
	while (cin >> N && N!=0){
		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] << endl;
	}
}