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 c1(int A,int B){
int C=1;
for(int I=0;I<B;I++){C=C*A;}
return C;
}

int c2(int X,int Y){
int D=1;
for(int H=0;H<Y;H++){D=D*(X-H);}
for(int H=1;H<=Y;H++){D=D/H;}
return D;
}

int think(int G,int Z){
int E,F;
int AL=0;
E=Z/2;
F=Z%2;
for(int V=0;2*V<=Z;V++){
AL+=c1(G,(E-V)+(F+2*V))*c2((E-V)+(F+2*V),E-V);
return AL;
}}


int main(){
int n;
cin>>n;
int a=n/3;
int b=n%3;
int al=0;

for(int i=0;3*i<=n;i++){
int x=a-i;
int y=b+3*i;
al+=think(a+1,y);
}

cout<<al<<" "<<(al+3649)/3650<<endl;

return 0;
}

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

int dp[50];

void print() {
   for (int i = 1; i < 33; i++) {
      cout << dp[i] << " ";
   }
   cout << endl;
}

void init() {
   dp[1] = 1, dp[2] = 2, dp[3] = 4;
   for (int i = 4; i < 33; i++) {
      dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
   }
}

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

   return 0;
}

C++: #include <iostream>
using namespace std;
int f(int n){
    if(n<0)
        return 0;
    if(n==0)
        return 1;
    if ( memo[n]!= -1 )
        return memo[n];
    return f(n-1)+f(n-2)+f(n-3);
}
 
int main(){
    int n;
    memo.resize(31,-1);
    while(1){
        cin >> n;
        if(n==0)
            break;
        int num=f(n);
        cout <<num/10/365+1<< endl;
    }
    return 0;  
}

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

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

using namespace std;

int main() {
    int n;
    
    vector<int> open(30);
    open[0] = 1;
    open[1] = 2;
    open[2] = 4;

    for ( int i = 3; i < 30; i++ ) {
        open[i] = open[i-1] + open[i-2] + open[i-3];
        // cout << i << ":" << open[i] << endl;
    }

    while(cin >>n, n) {
        n -= 1; // 添字に合わせる

        cout << (open[n]/10/365)+1 << endl;
    }
    
    return 0;
}

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

int main() {
    int n;
    long long dp[35];
    dp[0] = 1; //地面：１通り
    dp[1] = 1; //１段目：１通り
    dp[2] = 2; //２段目：２通り

    for (int i = 3; i <= 30; i++) {
        //一回に飛べるのが３段までなので
        dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
    }

    while (cin >> n && n) {
        long long ans = 0;
        ans = dp[n] / 3650;
        if (dp[n] % 3650) ans++;
        cout << ans << endl;
    }
    return 0;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	ll int a[31] = {0};
	a[1] = 1; a[2] = 2; a[3] = 4;
	FOR(i,4,31){
		a[i] = a[i-1] + a[i-2] + a[i-3];
	}
	int n;
	while(cin >> n, n){
		cout << ((a[n]%3650==0) ? a[n]/3650 : a[n]/3650 + 1) << endl;
	}
}

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

int memo[300];
int dp(int num);

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

		memset(memo, -1, sizeof(memo));

		cout << (int)ceil(dp(n) / 3650.0) << endl;
		//cout << dp(n) << endl;
		
	}

	return 0;
}

int dp(int num){
	if(num < 0) return 0;
	if(memo[num] != -1) return memo[num];
	if(num <= 1) return memo[num] = 1;

	return memo[num] = dp(num-1) + dp(num-2) + dp(num-3);
}

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

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

C++: #include <iostream>

using namespace std;

long long int kaidan (int n) {
	if (n == 0) {
		return 1;
	} else {
		if (n >= 3) {
			return kaidan(n-3)+kaidan(n-2)+kaidan(n-1);
		} else if (n > 1) {
			return kaidan(n-2)+kaidan(n-1);
		} else {
			return kaidan(n-1);
		}
	}
}


int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		long long int a = kaidan(n);
		long long int b;
		b = a / 10;
		if (a % 10 != 0) {
			b++;
		}
		a = b / 365;
		if (b % 365 != 0) {
			a++;
		}
		cout << a << endl;
	}
	return 0;
}

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

int main() {
	int DP[34]={0};
	int x;
	DP[0]=1;

	for(int i=0;i<=29;i++){
		for(int j=1;j<=3;j++)
		DP[i+j]+=DP[i];
	}
	while(true){
		cin >> x;
		if(x==0)
		break;
		cout << (DP[x]+3649)/3650 << endl; 
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int dfs(int n, int dan){

	if(dan == n){
		return 1;
	}
	else if(dan > n){
		return 0;
	}
	else{
		int count = 0;
		count = count + dfs(n, dan + 1);
		count = count + dfs(n, dan + 2);
		count = count + dfs(n, dan + 3);
		return count;
	}
}

int main(){
	
	int n;

	while(1){
		cin>>n;

		if(n == 0) break;

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

C++: #include<iostream>
#include<vector>
#include<string>
#include <cmath>
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
using namespace std;


int state(int n) {
	long long dp[35];
	int ans = 0;
	rep(i, 35)dp[i] = 0;
	dp[0] = 1;
	rep(i, n) {
		dp[i + 1] += dp[i];
		dp[i + 2] += dp[i];
		dp[i + 3] += dp[i];
	}
	ans = ceil(double(dp[n]) / 3650.0);
	return ans;
}

int main() {
	int n, m, a = 0;
	cin >> n;
	do {
		cout << state(n) << endl;
		cin >> n;
	} while (n > 0);
	return 0;
}

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

int dp[31];

void solve(int n)
{
  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];
}

int main()
{
  int n;
  while(1){
    cin >> n;
    if(n == 0){
      break;
    }else{
      solve(n);
      cout << ceil((double) (ceil((double) dp[n] / 10) / 365)) << endl;
    }
  }
}

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

int main(){
	int n=1;
	double ans =0;
	int checkc = 0;
	int i = 4;
	double check[3] = { 1, 2, 4 };
	
	while (n != 0){
		cin >> n;

		switch (n){
		case 1:
			ans = 1;
			break;
		case 2:
			ans = 2;
			break;
		case 3:
			ans = 4;
			break;
		default:
			while (n >= i){
				ans = check[0] + check[1] + check[2];
				i++;
				check[0] = check[1];
				check[1] = check[2];
				check[2] = ans;
			}
		}

		ans = ans / 3650;
		checkc = (int)(ans);

		if (ans > (double)(checkc)){
			checkc++;
		}
		if (ans != 0){
			cout << checkc << endl;
		}
		else{
			cout << endl;
		}
	}
	return 0;
}