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<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int dan[45]={0},nen[45]={0};
    int n;
    dan[1]=1;
    nen[1]=1;
    dan[2]=2;
    dan[3]=4;
    for(int i=4;i<=35;i++)
    {
        dan[i]=dan[i-1]+dan[i-2]+dan[i-3];
    }
    for(int i=2;i<=35;i++)
    {
        nen[i]=dan[i]/10/365;
        if(dan[i]*10/10%365!=0)
        {
            nen[i]++;
        }
    }
    while(cin>>n)
    {
        if(n==0)break;
        cout<<nen[n]<<endl;
    }
    return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <string>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;

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

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

int in;

int dfs(int num) {
  if (num == in) return 1;
  else if(num > in) return 0;
  return dfs(num+1) + dfs(num+2) + dfs(num+3);
}

int main() {
  while(1) {
    cin >> in;
    if (in == 0) break;
    int out = dfs(0);
    cout << out / 10 / 365 + 1 << endl;
  }
}

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

int dan;
long long int memo[40];

int main(){
  memo[1]=1;
  memo[2]=2;
  memo[3]=4;
  for(int i=4;i<31;i++){
    memo[i]=memo[i-1]+memo[i-2]+memo[i-3];
  }
  for(int i=1;i<31;i++){
    if(memo[i]%10==0){
      memo[i]=memo[i]/10;
    }
    else{
      memo[i]=memo[i]/10+1;
    }
  }

  for(int i=1;i<31;i++){
    if(memo[i]%365==0){
      memo[i]=memo[i]/365;
    }
    else{
      memo[i]=memo[i]/365+1;
    }
  }
  
  while(1){
    cin>>dan;
    if(dan==0){break;}
    cout<<memo[dan]<<endl;
  }
}

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

typedef long Int;

Int dp[100];

Int solve(Int n){
  Int rtn = 0;
  if(dp[n] != -1){
    rtn = dp[n];
  } else {
    if(n < 0){
      rtn = 0;
    } else if(n == 0){
      rtn = 1;
    } else {
      rtn = 0;
      rtn += solve(n-1);
      rtn += solve(n-2);
      rtn += solve(n-3);
    }
    dp[n] = rtn;
  }
  cout << n << " " << rtn << endl;
  return rtn;
}


int main(void){
  memset(dp,-1,sizeof(dp));
  Int n;
  while(cin >> n , n){
    cout << solve(n)/10/365 + 1 << endl;
  }
  return 0;
}

C++: #include <cstdio>

int n;
int s[31];

int main(){
	s[0] = 1;
	for(int i = 0; i < 31; i++){
		for(int j = 1; j <= 3; j++){
			if(i-j < 0) break;
			s[i] += s[i-j];
		}
	}
	while(scanf("%d", &n),n) printf("%d\n", s[n]/3650+(!(s[n]%365==0)));
}

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

int main(){
    while(1){
        int n=0;
        cin>>n;
        if(n==0)break;
        int p[45]={0};
        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];
        }
        cout<<(p[n]/3650)+1<<endl;
    }
    return 0;
}

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



int main(){
	unsigned long int dp[40];
	dp[0]=1;
	dp[1]=1;
	dp[2]=2;
	for(int i=3;i<40;i++){
		dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
	}
	int n;
	while(cin>>n,n){
		int ans=dp[n]/10/365 +1;
		cout<<ans<<endl;
	}
}

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

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

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

    int ans = stairs[n];
    if (ans % 10 != 0)
      ans += 9;
    ans /= 10;

    if (ans % 365 != 0)
      ans += 364;
    ans /= 365;

    cout << ans << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int stair(int n){
	if(n==1)
		return 1;
	else if(n==2)
		return 2;
	else if(n==3)
		return 4;
	else 
		return stair(n-1)+stair(n-2)+stair(n-3);
}

int main(){
	int n;
	while(scanf("%d",&n) && n!=0){
		int year = stair(n)/3650;
		if(stair(n)%3650!=0)  year++;
		cout<<year<<endl;
	}

	return 0;
}

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

int main() {
  int n;
  int dp[31];
  
  while(cin>>n, n) {
    fill(dp, dp+31, 0);
    dp[0]=dp[1]=1; dp[2]=2; dp[3]=4;
    for(int i=4; i<=n; i++) {
      dp[i]=dp[i-3]+dp[i-2]+dp[i-1];
    }

    cout << dp[n]/3650+1 << endl;
  }

  return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int dp[111];

signed main(){
    int N;
    while(cin>>N,N){
        dp[0]=1;
        for(int i=1;i<=N;i++){
            dp[i]=0;
            for(int j=1;j<=3;j++)if(i-j>=0)dp[i]+=dp[i-j];
        }
        cout<<((dp[N]+9)/10+364)/365<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

ll step(ll n)
{
  if(n==2)return 2;
  if(n==1)return 1;
  if(n==0)return 1;

  ll a=step(n-1)+step(n-2)+step(n-3);

  return a;
}

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

    ll day=(step(n)+9)/10;

    cout<<(day+364)/365<<endl;

  }
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repn(i,n,m) for(int i=n;i<m;i++)
#define repn1(i,n,m) for(int i=n;i<=m;i++)
using namespace std;

int main(){

	int dp[100] = {0};
	int n;
	
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;

	repn(i, 4, 30) dp[i] = dp[i-1] + dp[i-2] + dp[i-3];

	while(cin >> n, n){

		cout << dp[n] / 3650 + (dp[n]%3650==0 ? 0 : 1) << endl;
	}

	return 0;
}