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>
#include <cmath>
using namespace std;

int dp[31];

const int DIV = 3650;

int main(void)
{
	while(1){
		int num;
		cin >> num;
		if(num == 0)
			return 0;
		memset(dp,0,sizeof(dp));
		dp[0] = 1;
		for(int i=1;i<=num;++i){//どの段から？
			for(int j=1;j<=3;++j){//何段？
				if(i-j < 0)
					continue;
				dp[i] += dp[i-j];
			}
		}
		cout << ceil((double)dp[num]/DIV) << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#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 it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int in[31]={1,1,2};
  loop(i,3,31)in[i]=in[i-1]+in[i-2]+in[i-3];

  int n;
  while(cin>>n,n){
    cout<<(in[n]-1)/3650+1<<endl;
  }

}

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


void solve(vector<int>& a) {
    a[0] = 1;
    for(int i = 1; i <= 30; i++) {
        if(i == 1) {
            a[i] = a[i - 1];
        } if(i == 2) {
            a[i] = a[i - 1] + a[i - 2];
        } else {
            a[i] = a[i - 1] + a[i - 2] + a[i - 3];
        }
    }
    for(int i = 1; i <= 30; i++) {
        a[i] = (a[i] + (3650 - 1)) / 3650;
    }
}

int main() {
    vector<int> a(31);
    solve(a);
    vector<int> inpArray;
    int inp;
    do {
        cin >> inp;
        inpArray.push_back(inp);
    } while(inp != 0);

    for(int i = 0; i < (int)inpArray.size() - 1; i++)
        cout << a[inpArray[i]] << endl;

    return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>

int compare_int(const void* a, const void* b) { return *(int*) a - *(int*) b; }

int n, dp[30];

int func(int p) {
	if (p == n) {
		return 1;
	}
	int cnt = 0;
	for (int i = p+1; n >= i && 3+p >= i; i++) {
		if (!dp[i]) dp[i] = func(i);
		cnt += dp[i];
	}
	return cnt;
}

int main() {
	while(scanf("%d", &n) != EOF){
 if(n == 0) return 0;
memset(dp, -1, sizeof(dp));
	printf("%d\n", (func(0)/10+364)/365);
}
}

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

int main(){
	vector<long> cnt(30, 0);
	cnt[0] = cnt[1] = cnt[2] = 1;
	for(int i = 0; i < 30; i++){
		for(int j = 1; j <= 3; j++){
			if(i+j < 30) cnt[i+j] += cnt[i];
		}
	}
	int n;
	while(cin >> n && n) cout << cnt[n-1] / 3650 + 1 << endl;
	return 0;
}

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

int fib[100];

int fibonacci(int n){
  if(!fib[n]) fib[n] = fibonacci(n-1) + fibonacci(n-2) + fibonacci(n-3);
  return fib[n];
}

int main(){
  int n;
  memset(fib, 0, sizeof(fib));
  fib[0] = fib[1] = 1;
  fib[2] = 2;
  while((cin >> n), n){
    cout << (fibonacci(n)/3650 + 1) << endl;
  }
  return 0;
}

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

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

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

    cout << ans[n] << endl; 
  }
  
  return 0;
}

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

int dp[100];

int main(){
	int n;
	while(cin >> n){
		if(n == 0){
			break;
		}
		memset(dp,0,sizeof(dp));
		dp[1] = 1;
		dp[2] = 1;
		dp[3] = 1;
		for(int i=1;i<n;i++){
			dp[i+1] += dp[i];
			dp[i+2] += dp[i];
			dp[i+3] += dp[i];
		}

		dp[n] /= 10;
		int add = 0;
		if(dp[n]%365 != 0 || dp[n] == 0){
			add++;
		}

		cout << dp[n]/365+add << endl;
	}
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int n;
LL memo[31];

LL solve(int cnt){
	if(cnt >= n) return cnt > n? 0 : memo[cnt] = cnt == n;
	if(memo[cnt] != -1) return memo[cnt];
	LL res1 = solve(cnt + 1);
	LL res2 = solve(cnt + 2);
	LL res3 = solve(cnt + 3);
	return memo[cnt] = res1 + res2 + res3;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	while(1){
		rep(i,31)
			memo[i] = -1;
		cin >> n;
		if(n == 0) break;
		LL ans = solve(0);
		ans = (ans + 10 - 1) / 10;
		ans = (ans + 365 - 1) / 365;
		cout << ans << endl;
	}

	return 0;
}

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

const int MAXN = 31;

lli dp[MAXN];

int main() {
  dp[0] = 1;
  for(int i = 0; i < MAXN; ++i) {
    for(int j = 1; j <= 3 && i+j < MAXN; ++j) {
      dp[i+j] += dp[i];
    }
  }
  for(lli n; cin >> n, n;) {
    cout << ( (dp[n]+9)/10 + 364 ) / 365 << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n;
    int a[15000] = {0};
    while(scanf("%d",&n),n){
    int ans = 0;
    a[0] = 1;
    a[1] = 1;
    a[2] = 2;
    for(int i = 3;i <= n; i++){
        a[i] = a[i-1] + a[i-2] + a[i-3];
    }
    ans = a[n]/365;
    printf("%d\n",ans+1);
    }
    return 0;
}

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

int main(void){
	const int ofDay = 10;
	const int MAXN = 30;
	const int TOBIN = 3;
	const int YEAR = 365;
	int dp[MAXN+1];
	int tobi[TOBIN] = {1,2,3};
	
	// init
	for(int i=1; i<=MAXN; i++)
		dp[i] = 0;
	dp[0] = 1;

	// 全通り計算
	for(int i=1; i<=MAXN; i++){
		for(int j=1; j<=TOBIN; j++){
			if( i+j <= MAXN )
				dp[i+j] += dp[i];
		}
	}

	// 年数計算
	for(int i=1; i<=MAXN; i++){
		dp[i] = dp[i] / ofDay + (dp[i] % ofDay ? 1 : 0);
		dp[i] = dp[i] / YEAR + (dp[i] % YEAR ? 1 : 0);
	}

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

		cout << dp[n] << endl;
	}

	return 0;
}

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

int main(){
  int n,c=0;
  while(true){
  cin>>n;
  if(n==0)
    break;
  int dp[n+1];
  for(int i=0;i<n+1;i++){
    if(i==0){
      dp[i]=1;
    }
    if(i==1){
      dp[i]=1;
    }
    if(i==2){
      dp[i]=2;
    }
  }
  
  for(int i=3;i<n+1;i++){
      dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
  }
  if(c==0){
    cout<<endl;
    ++c;
  }
  cout<<dp[n]/3650+1<<endl;
  }
}

C++: #include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;

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