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 <bits/stdc++.h>

using namespace std;

int nenn(int sum,int a)
{
	if(sum==a){
		return 1;
	}
	int res=0;
	if(sum+1<=a){
		res=res+nenn(sum+1,a);
	}
	if(sum+2<=a){
		res=res+nenn(sum+2,a);
	}
	if(sum+3<=a){
		res=res+nenn(sum+3,a);
	}
	return res;
}
int main(void)
{
	while(true){
		int x;
		int y,z;
		cin>>x;
		if(x==0){
			break;
		}
		if(nenn(0,x)%10==0){
			y=nenn(0,x)/10;
		}else{
			y=nenn(0,x)/10+1;
		}
		if(y%365==0){
			z=y/365;
		}else{
			z=y/365+1;
		}
		cout<<z<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed 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]+9)/10+364)/365<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
      int tmp;
      int dp[30];
      cin>> tmp;
      do{
            fill(dp,dp+30,0);
            dp[0] = 1;
            for (int i = 0; i<tmp;i++)
            {
                  for(int j = 1;j < 4;j++)
                        dp[i+j] += dp[i];
            }
            cout << dp[tmp]/3650 + 1<<endl;
            cin >> tmp;
      }while(tmp);

}

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

int main() {
	int a[30];
	a[0] = 1;
	a[1] = 1;
	a[2] = 2;
	for ( int i = 3; i <= 30; i++ )
		a[i] = a[i - 1] + a[i - 2] + a[i - 3];
	while (1) {
		int n;
		cin >> n;
		if ( n == 0 ) break;
		cout << a[n] << endl;
	}
}

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

int memo[31];

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

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

int num(int n);

int main(){
  int n;
  cin>>n;
  cout << num(n)/3650 + 1<<endl;
}

int num(int n){
    switch (n)
    {
        case 0: return 1;
        case 1:  return 2;
        case 2:  return 4;
    }
  return num(n-1)+num(n-2)+num(n-3);
}

C++: #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef pair<int, int> P;
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;
}

const int INF = 1001001001;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, -1, 0, 1};

vector<int> vec;
vector<int> ans_vec;

int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0) break;
    vec.push_back(n);
  }

  for (auto&& n : vec) {
    vector<int> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;

    for (int i = 2; i <= n; i++) {
      dp[i] += dp[i - 1] + dp[i - 2];
      if (i > 2) {
        dp[i] += dp[i - 3];
      }
    }

    int ans = ceil(ceil((double)dp[n] / 10.0) / 365.0);
    ans_vec.push_back(ans);
  }

  for (auto&& i : ans_vec) {
    printf("%d\n", i);
  }
}

C++: #include <iostream>

using namespace std;

int dp[31];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(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];
        }
    }

    while(true) {
        int N;
        cin >> N;
        if(!N) break;
        cout << (dp[N]+3650-1)/3650 << endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <string.h>

int main(void) {
	int n,i,j;
	int data[31];
	
	while(1){
		scanf("%d",&n);
		if(!n) break;
		memset(data,0,sizeof(data));
		data[0] = 1;
		for(i = 0;i < n;i++){
			for(j = 1;j <= 3;j++){
				data[i+j] += data[i];
			}
		}
		printf("%d\n",(data[n]+3649)/3650);
	}
	
	return 0;
}

C++: #include <stdio.h> #include <iostream> #include <cstdio> using namespace std; int x, c=0; void dfs(int pos) { if (pos == 1) { c++; return; }else if (pos == 2) { c = c + 2; return; } else if (pos == 3) { c = c + 4; return; } else { dfs(pos - 1); dfs(pos - 2); dfs(pos - 3); } } int main() { while (1) { int days = 0, years = 0; c = 0; cin >> x; if (x == 0) { break; } dfs(x); days = c / 10; if (c % 10 != 0) { days++; } years = days / 365; if (days % 365 != 0) { years++; } cout << years << endl; } }

C++: #include<stdio.h>

int main(){

int x[32]={1,2,4};
for(int i=3;i<31;i++)
x[i]=x[i-1]+x[i-2]+x[i-3];

int n;
while(1){
scanf("%d",&n);if(n==0)break;
int d=x[n-1];
int y=d/365/10+1;
printf("%d\n",y);
}
return 0;
}

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

const int n_MAX = 31;
const int mod = 10 * 365;

int main() {
  int count;
  int data[n_MAX];
  long long dp[n_MAX];

  for (int i = 0; i < n_MAX; ++i) {
    cin >> data[i];
    if (data[i] == 0) {
      count = i;
      break;
    }
  }

  for (int i = 0; i < n_MAX; ++i) {
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;
  }

  for (int i = 3; i < n_MAX; ++i) {
    dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
  }

  for (int i = 0; i < count; ++i) {
    int ans = 0;
    if (dp[data[i]] % mod == 0) {
      ans = dp[data[i]] / mod;
    } else {
      ans = (dp[data[i]] / mod) + 1;
    }
    cout << ans << endl;
  }

  return 0;
}

C++: #include<iostream>

using namespace std;

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

long long dp[40];

int main() {
  dp[0] = 1;
  dp[1] = 1;
  dp[2] = 2;
  rep (i, 30) dp[i + 3] = dp[i] + dp[i + 1] + dp[i + 2];
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    cout << ((dp[n] + 9) / 10 + 364) / 365 << endl;
  }
  return 0;
}

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

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){
        int n;
        scanf("%d",&n);
        if(n == 0)break;
        printf("%.0f\n",ceil(dp[n-1]/(365.0*10.0)));
    }

    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];
        printf("%d\n",dp[i]);
    }
    while(1){
        scanf("%d",&n);
        if(n==0) return 0;
        printf("%d\n",(int)((dp[n-1]+9)/10+364)/365);
    }
}