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<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	unsigned long long dp[100];
	dp[0] = 0;
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;
	rep(i,4,40){
		dp[i] = dp[i-1] + dp[i-2] + dp[i-3];	
		//cout << dp[i] << endl;
	}
	
	rep(i,0,40){
		if(dp[i] % 10 )
			dp[i] = dp[i] / 10 + 1;
		else
			dp[i] = dp[i] / 10;
	}
	
	

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

	ret 0;
}

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

int n;
int memo[35];

int solve(int n){
  if(memo[n] != -1)return memo[n];
  int rec = 0;
  if(n == 0 || n == 1)return memo[n] = 1;
  else if(n == 2)return memo[n] = 2;
  for(int i = 1;i <= 3;i++){
    rec += solve(n - i);
  }
  return memo[n] = rec;
}

int main(){
  while(cin >> n , n){
    memset(memo,-1,sizeof(memo));
    int ans = solve(n);
    cout << (ans - 1) / 3650 +1 <<endl;
  }
}

C++: #include<stdio.h>
int n;

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

int main()
{
    while(1)
    {
        scanf("%d",&n);
        if(n==0)break;
        printf("%d\n",(((fn(n)+10-1)/10)+365-1)/365);
    }
    return 0;
}

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

const long long INF = 1LL << 60;

long long dp[40];

long long rec(int i){
    if(i == 0) return 1;
    
    long long res = 0;
    for(int j = 1; j <= 3; j++){
        if(i - j >= 0) res += rec(i - j);
    }
    return dp[i] = res;
}

int main(){
  for(int i = 0; i < 40; i++){
    dp[i] = INF;
  }
    while(true){
        int n; cin >> n;
        if(n == 0) break;
        int tmp = rec(n);
        if(tmp % 3650 == 0){
            cout << tmp/3650 << endl;
        }
        else{
            cout << tmp/3650 + 1 << endl;
        }
    }
}

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

int main(void){
	int s[31] = {1, 1, 2};
	int n;
	
	for(int i = 3; i <= 30; i++){
		s[i] = s[i-1] + s[i-2] + s[i-3];
	}

	while(true){
		cin >> n;
		if(!n) break;
		cout << (s[n] / 365 / 10) + 1 << endl;
	}

  return 0;
}

C++: #include <iostream>
using namespace std;
int a,cou,sum,now;

void dfs(int now){
  if(now==a)cou++;
  if(now+1<=a){
    dfs(now+1);
  }
  if(now+2<=a){
    dfs(now+2);
  }
  if(now+3<=a){
    dfs(now+3);
  }
}

int main(){
  while(1){
    cin >> a;
    if(a==0)break;
    cou=0;
    now=0;
    dfs(now);
    if(cou%10!=0)cou=cou/10+1;
    else cou=cou/10;
    if(cou%365!=0)cou=cou/365+1;
    else cou=cou/365;
    cout <<cou<<endl;
  }
  return 0;
}

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

int main()
{
	int n = 1, dp[40] = {1};
	rep(i, 31) {
		if (i == 0) continue;
		if (i >= 1) dp[i] += dp[i - 1];
		if (i >= 2) dp[i] += dp[i - 2];
		if (i >= 3) dp[i] += dp[i - 3];
	}
	while (true) {
		cin >> n;
		if (!n) break;
		cout << (dp[n] + 3649)/ 3650 << endl;
	}
}

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

#define int long long

int dp[50];
int n;

void init() {
  dp[0] = 1;
  for (int i = 0; i <= 30; i++) {
    for (int j = 1; j <= 3; j++) {
      dp[i+j] += dp[i];
    }
  }
}

signed main() {
  init();
  while (1) {
    cin >> n;
    if (n == 0) break;
    int mult = 3650;
    cout << (dp[n] + mult - 1) / mult << endl;
  }

  return 0;
}

C++: #include<iostream>

using namespace std;

int func(int n) {
	long long memo[100] = { 0 };
	memo[1] = 1;
	memo[2] = 2;
	memo[3] = 4;
	for (int i = 4; i <= n; i++) {
		memo[i] += memo[i - 1] + memo[i - 2] + memo[i - 3];
	}
	return memo[n] / (10 * 365) + 1;
}

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

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

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

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

int  N, A[128];

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

	}

C++: #include<iostream>
int n,s[33]={1},t;main(){for(;n<33;s[n]+=t,s[n+1]+=t,s[n+2]+=t)t=s[n++];for(;std::cin>>n,n;)printf("%d\n",(s[n]-n)/10/365+1);return 0;}

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

using namespace std;

int n;

int dp[35][35];

void solve() {
	memset(dp, 0, sizeof(dp));
	
	dp[0][0] = 1;
	for (int i=0; i<n; i++) {
		for (int j=0; j<=n; j++) {
			if (j>=1) dp[i+1][j] += dp[i][j-1];
			if (j>=2) dp[i+1][j] += dp[i][j-2];
			if (j>=3) dp[i+1][j] += dp[i][j-3];
		}
	}
	
	int sum = 0;
	for (int i=0; i<n; i++) {
		sum += dp[i+1][n];
	}
	sum /= 10;
	int ans = ceil((double)sum/365.0);
	if (sum > 0) cout << ans << endl;
	else cout << 1 << endl;
}

int main() {
	while (1) {
		cin >> n; if (n==0) break;
		solve();
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int a[31] = { 0, 1, 2, 4 };
    for( int i=4; i<=30; ++i ) {
        a[i] = a[i-1] + a[i-2] + a[i-3];
    }

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

        cout << ( a[n] / 10 / 365 ) + ( a[n] / 10 % 365 != 0 ) << endl;
    }
}