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>

using namespace std;

int dp[31];

int main()
{
	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 (scanf("%d", &n), n) {
		printf("%d\n", dp[n]);
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> dp(31);
  dp.at(0)=1;
  for(int i=0;i<30;i++){
    dp.at(i+1)+=dp.at(i);
    if(i<29){
      dp.at(i+2)+=dp.at(i);
    }
    if(i<28){
      dp.at(i+3)+=dp.at(i);
    }
  }
  while(true){
    int N;
    cin >> N;
    if(N==0){
      break;
    }
    cout << (dp.at(N)+3649)/3650 << endl;
  }
}

C++: #include <iostream>

using namespace std;

int n;
int memo[31];

int dfs(int num)
{
	
	int sum = 0;

	if(memo[num] != -1)
	{
		return memo[num];
	}

	if(num == n)
	{
		return 1;
	}

	if(num < n)
		sum += dfs(num + 1);

	if(num < n)
		sum += dfs(num + 2);

	if(num < n)
		sum += dfs(num + 3);

	memo[num] = sum;

	return sum;
}

int main()
{

	while(1)
	{
		cin >> n;

		for(int i = 0; i <= 31; i++)
		{
			memo[i] = -1;
		}

		if(n == 0)
		{
			break;
		}

		cout << dfs(0)/10/365+1 << endl;
	}
}

C++: //40
#include<iostream>

using namespace std;

int main(){
  int w[33]={1};
  for(int i=0;i<=29;i++){
    w[i+1]+=w[i];
    w[i+2]+=w[i];
    w[i+3]+=w[i];
  }
  for(int n;cin>>n,n;){
    cout<<(w[n]+3649)/3650<<endl;
  }
  return 0;
}

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

int dp[30];

void makedp(){
  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];
}

int solve(int n){
  n--;
  int day = dp[n]/10;
  if(dp[n]%10) day++;

  int year = day/365;
  if(day%365) year++;

  return year;
}

int main(){
  makedp();
  for(;;){
    int n;
    cin >> n;
    if(!n) break;
    cout << solve(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;
		if(memo[n]%365!=0)ans=memo[n]/(365*10)+1;
		else ans=memo[n]/(365*10);
		cout<<ans<<endl;
	}
	
	return 0;
}

C++: #include<iostream>

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

C++: #include<iostream>
using namespace std;
int n;
int mamo[31], ans[31];
int main(){
  while(cin>>n){
    if(!n)
      return 0;
    memo[0]=1;
    memo[1]=1;
    memo[2]=2;
    for(int i=3;i<=n;i++){
      if(!memo[i]){
	memo[i]=memo[i-1]+memo[i-2]+memo[i-3];
      }
    }
      if(memo[n]%3650)
      ans[n]+=1;
      ans[n]+=memo[n]/3650;
      cout<<ans[n]<<endl;
  }
  return 0;
}

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

#if 0
所用時間:

感想:

#endif

int N; int A[30];

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

C++: #include <iostream>
using namespace std;
#define rep(i,x,to) for(int i=x;i<to;i++)

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

C++: #include<iostream>

using namespace std;

int main(){

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

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

        cout<< (dp[n]+3600-1)/3600<< endl;
    }

    return 0;
}

C++: #include <iostream>
using namespace std;
int num(int n);
int main(){
  int n;cin >> n;
  cout << num(num(n)/3650+1) <<endl;
}

int num(int n){
  if(n<0)return 0;
  if(n==0)return 1;
  return num(n-1)+num(n-2)+num(n-3);
}

C++: #include <iostream>
using namespace std;
#define rep(i,x,to) for(int i=x;i<to;i++)

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

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

using namespace std;

/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)  //a~(b - 1)?????§
#define print(i) cout << i << endl //?°??????????Python?????????
#define all(i) (i).begin(),(i).end() //??¨??????(sort??¨???)
#define mp make_pair //mp(OO, OO)??¨???:::pint??¨???

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/

int main(void)
{
  int n;
  int dp[35] = {1, 1, 2};

  FOR(i, 3, 31){
    dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
  }

  while (cin >> n){
    if (n == 0) break;
    cout << dp[n] / 10 / 365 + 1 << endl;
  }

  return 0;
}

C++: 

#include <algorithm>
#include <iostream>
using namespace std;

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

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-8;
const long long inf=1e16;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int dp[31]={1,1,2};
	loop(i,3,31)dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
	int n;
	while(cin>>n,n){
		int t=dp[n];
		t=(t-1)/10+1;
		cout<<((t-1)/365+1)<<endl;
	}
//	rep(i,31)cout<<dp[i]<<endl;
}

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

int main()
{
	int n, i;
	vector<int> stairs;

	while (cin>>n, n) {
		stairs.clear();
		stairs.resize(n+3);
		stairs[0] = 1;
		for (i = 0; i < n; i++) {
			stairs[i+1] += stairs[i];
			stairs[i+2] += stairs[i];
			stairs[i+3] += stairs[i];
		}
		cout<<((stairs[n]+9)/10+364)/365<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <vector>
#include <set>
#include <queue>

using namespace std;

int main(){
	int dp[31];
	dp[0] = 1;
	dp[1] = 1;
	for(int i=2;i<31;i++){
		dp[i] = 0;
		for(int j=1;j<=3;j++){
			if(i-j<0)break;
			dp[i] += dp[i-j];
		}
	}
	for(int i=0;i<31;i++){
		dp[i] = (dp[i]+3649)/3650;
	}
	while(true){
		int x;
		scanf("%d",&x);
		if(x==0)break;
		printf("%d\n",dp[x]);
	}
	return 0;
}