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;

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int div1(ll x){
  return x%1000000007;
}

main(){
    int st[31];
    st[0]=1;
    st[1]=1;
    st[2]=2;
    for (int i=3;i<31;i++){
        st[i]=st[i-1]+st[i-2]+st[i-3];
    }
    int n=in();
    while(n!=0){
        cout << (st[n]+3650-1)/3650 << endl;
        n=in();
    }
}

C++: #include <iostream>
//#define int long long
using namespace std;
int N, A[35];
int solve(){
    A[0] = 1;
    A[1] = 1;
    A[2] = 2;
    A[3] = 4;
    for(int i=4; i<=N; i++){
        A[i] = A[i-3] + A[i-2] + A[i-1];
    }
    return A[N];
}

signed main(){
    N = 30;
    solve();
    while(cin >> N && N > 0){
        cout << (A[N]-1)/3650+1 << 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;

	while(cin >> n, 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];

	

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

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
int dp[31];
int main() {
  int n;
  int inf = 1 << 30;
  dp[0] = 1;
  for(int i = 1; i <= 30; i++){
    dp[i] += dp[i -1];
    if(i > 1) dp[i] += dp[i - 2];
    if(i > 2) dp[i] += dp[i - 3];
  }
  while(1){
    cin >> n;
    if(n == 0) break;
    cout << ceil(dp[n] / 10.0 / 365.0) << endl;
  }
}

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

int n,dp[35];

int func(){
	n+=2;
	dp[2]=1;
	for(int i=3;i<=n;i++){
		dp[i]=dp[i-3]+dp[i-2]+dp[i-1];
	}
	int ans=((dp[n]-1)/10)/365+1;
	return ans;
}

int main(){
	while(1){
		cin>>n;
		if(n==0) break;
		cout<<func()<<endl;
	}
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <algorithm>
using namespace std;
const int INF = 100000000;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n;
	while (cin >> n && n){
		//dp[n]はn段目に行く登り方の種類
		int dp[31];
		dp[0] = 1; dp[1] = 1; dp[2] = 2;
		for (int i = 3; i <= n; i++){
			dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
		}
		int cnt = dp[n];
		if (cnt % 10){
			cnt = cnt / 10 + 1;
		}
		else{
			cnt = cnt / 10;
		}
		if (cnt % 365){
			cnt = cnt / 365 + 1;
		}
		else{
			cnt = cnt / 10;
		}
		cout << cnt << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int n , now = 0;
int saiki(int now){
	if( now == n )
		return 1;
	if( now > n )
		return 0;
	int res = 0;
	res += saiki(now+1)+saiki(now+2)+saiki(now+3);
	return res;
}
int main(){
	while(1){
		cin >> n;
		if( n==1 ){
			cout << 1 << endl;
			continue;
		}
		if( n==0 ) break;
		int count = saiki(0);
		count = count / 10;
		int x = count / 365 ;
		if(count%365>0)
			x ++;
		cout << x << endl;
}
}

C++: #include<iostream>

using namespace std;
int dp[31] ={1,2,4},step;
int main(){
  for(int i=3;i<31;i++){
    dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
  }
  while(cin>>step,step){
    cout<<(dp[step-1])/3650+1<<endl;
  }
  
  return 0;
}

C++: #include<iostream>

using namespace std;

int main(){

	int n;
	int dp[32];
	int ans;

	memset(dp, 0, sizeof(dp));

	while(n>0){

		cin >> n;

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

		ans = dp[n] / 3650;
		if(dp[n]%3650 != 0){
			ans++;
		}

		cout << ans << endl;

	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define v vector<long long>
using namespace std;
using ll = long long;

// ----本問について----
// 問題：観音堂
// 問題文URL：https://onlinejudge.u-aizu.ac.jp/problems/0168
// 所要時間：15分
// 学んだこと：DPの基礎
// ------------------

// ----ここから本問のソースコード----

const ll N_MAX = 30 + 10;

// グローバル変数（入力）
ll n, dp[N_MAX];

ll solve(ll i) {                     // メモ化再帰（？）
  if (dp[i] != -1) { return dp[i]; } // 計算済みならその値を返す

  if (i == 0) {
    dp[i] = 1;
  } else if (i == 1) {
    dp[i] = solve(i - 1);
  } else if (i == 2){
    dp[i] = solve(i - 1) + solve(i - 2);
  } else {
    dp[i] = solve(i - 1) + solve(i - 2) + solve(i - 3);
  }

  return dp[i];
}

int main() {
  // cout << fixed << setprecision(10);
  rep(i, N_MAX) { dp[i] = -1; }
  while (cin >> n && n > 0){
    cout << ceil(solve(n)/3650.0) << 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(step_num < 0)  return 0;
  else if(memo[step_num][step_kind].count)  return memo[step_num][step_kind].count;
  for(int i = 1; i < 4; ++i) kind_count = kind_count + ProgressNumberOfYears(step_num - i,i);


  memo[step_num][step_kind].count = kind_count;
  //memo[step_num][step_kind].flag = true;

  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 <iostream>
using namespace std;


int main() {
    int n;
    long long count[31];

    fill(count, count+31, 0);
    count[0] = 1;
    for (int i = 1; i <= 30; i++) {
        count[i] += count[i-1];
        if (i >= 2) {
            count[i] += count[i-2];
        }
        if (i >= 3) {
            count[i] += count[i-3];
        }
    }

    while (cin >> n, n) {
        cout << (count[n] / 3650 + (count[n]%3650 > 0)) << endl;
    }

    return 0;
}

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

int main() {
  int a;
  int dp[31] = {1};
  for(int i = 0; i < 31; i++) {
    for(int j = 1; j <= 3; j++) {
      dp[i + j] += dp[i];
    }
  }
  while(cin >> a) {
    if(a == 0) break;
    if(dp[a] % 3650 == 0) {
      cout << dp[a] / 3650 << endl;
    }else {
      cout << dp[a] / 3650 + 1 << endl;
    }
  }
}