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 <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <unordered_set>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 1000000009;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()

int main()
{
	int n;
	vector<int> dp(35);
	dp[0] = 1;
	REP(i, 30)REP(j, 3)dp[i + 1 + j] += dp[i];
	while (cin >> n)
	{
		cout << (dp[n] / 3650 + !!(dp[n] % 3650)) << endl;
	}
	return 0;
}

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

int dp[31];
int n;

int solve( int now ) {
  if( n == now ) return 1;
  if( dp[now] ) return dp[now];

  int sum = 0;
  for(int i=1; i<=3; i++) {
    if( now + i <= n ) sum += solve( now + i );
  }

  return dp[now] = sum;
}

int main()
{
  while( cin >> n, n ) {
    fill_n(dp, 31, 0);
    int ans = solve( 0 );
    if( ans % 3650 == 0 ) {
      cout << ans / 3650 << endl;
    } else {
      cout << ans / 3650 + 1 << endl;
    }
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL<<60;

int dp[30];

void solve(int n) {
    dp[0] = 1;

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

    int day = (dp[n]+9)/10;
    int ans = (day+364)/365;
    cout << ans << endl;
}

int main() {
    while (true) {
        memset(dp, 0, sizeof(dp));
        int n; cin >> n;
        if (n) solve(n);
        else break;
    }

    return 0;
}

C++: #include <iostream>

#define MAX_N 30
#define INF -1

int memo[MAX_N], ans, n;

void solve();

int dp(int a);

int answer(int in);

int main(){
    while(true){
        std::cin >> n;
        
        if(n == 0)
            break;
        
        for(int i = 0; i < MAX_N; ++i)
            memo[i] = INF;
        
        solve();
        
        std::cout << answer(ans) << std::endl;
    }
    return 0;
}

void solve(){
    ans = dp(n + 1);
    return;
}

int dp(int a){
    if(a < 1) return 0;
    if(a == 1) return 1;
    
    if(memo[a] == INF){
        memo[a] = dp(a - 1) + dp(a - 2) + dp(a - 3);
        return memo[a];
    }
    
    return memo[a];	
}

int answer(int in){
    int count = 1;
    in /= 10;
    while(true){
        if(in <= 365) break;
        in -= 365;
        ++count;
    }
    return count;
}

C++: #include <algorithm>
#include <iostream>

using namespace std;

int hoge[124], n;

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

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	long long dan[31] = {1,1,2};
	for(int i=3;i<31;i++){
		dan[i] = dan[i-3] + dan[i-2] + dan[i-1];
	}
	while(cin >> n,n){
		int year = dan[n] / 10 / 365;
		if((double)dan[n] / 10.0 / 365.0 - year > 0)year++;
		cout << year << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
      int tmp;
      int dp[31];
      cin>> tmp;
      do{
            fill(dp,dp+31,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 result[31];
	result[0] = 1;
	result[1] = 1;
	result[2] = 2;
	for (int i = 3; i < 31; i++) {
		result[i] = result[i - 1] + result[i - 2] + result[i - 3];
	}
	
	int n;
	while (cin >> n, n) {
		cout << result[n] / 3650 + 1 << endl;
	}
	return 0;
}

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+3649)/3650<<endl;

return 0;
}

C++: #include <iostream>
using namespace std;
long long dp[10000][10000] = { 0 }, cnt = 0;
int main() {
	while (1) {
		cnt = 0;
		int n;
		cin >> n;
		if (n == 0) return 0;
		dp[0][0] = 1;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (i - 3 >= 0) dp[i][j] = dp[i - 1][j - 1] + dp[i - 2][j - 1] + dp[i - 3][j - 1];
				else if (i - 2 >= 0) dp[i][j] = dp[i - 1][j - 1] + dp[i - 2][j - 1];
				else dp[i][j] = dp[i - 1][j - 1];
			}
		}
		for (int i = 1; i <= 30; i++) {
			cnt += dp[n][i];
		}
		//cout << cnt << endl;
		if (cnt % 10) {
			cnt = cnt / 10 + 1;
		}
		else cnt /= 10;
		if (cnt % 365 == 0) cout << cnt / 365 << endl;
		else cout << cnt / 365 + 1 << endl;
	}
	return 0;
}

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))

#define MOD(x, y) ((x) % (y))
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))
#define DIVFLOOR(x, y) (((x) + ((y) / 2)) / (y))
#define DIVROUND(x, y) ((x) - MOD(x, y) >= MOD(x, y) ? DIVCEIL(x, y) : DIVFLOOR(x, y))

constexpr int MAX_N = 30;

long long dp[MAX_N+3];

int main() {
  dp[0] = 1;

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

  while (true) {
    int N; cin >> N;
    if (!N) break;
    cout << DIVCEIL(dp[N], 3650) << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

int main(void){
	int i, j, n, dp[31];
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		fill(dp,dp + 31,0);
		dp[0] = 1;
		for(i = 0;i < n;i++){
			for(j = 1;j <= 3;j++){
				if(i + j <= n){
					dp[i + j] += dp[i];
				}
			}
		}
		cout << dp[n] / 3650 + 1 << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

main(){
  long long dp[31];
  for(int i=0;i<31;i++){
    dp[i]=0;
  }
  dp[0]=1;
  for(int i=0;i<31;i++){
    int t=i+1;
    if(t<31) dp[t++]+=dp[i];
    if(t<31) dp[t++]+=dp[i];
    if(t<31) dp[t]+=dp[i];
  }

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

    if(dp[n]%365==0){
      cout << dp[n]/3650 << endl;
    }else{
      cout << dp[n]/3650+1 << endl;
    }
  }
  return 0;
}