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>

using namespace std;

int main(){
  int n, i;
  while(cin >> n && n != 0) {
    int dp[n+1] = {};
    dp[1] = 1;
    dp[2] = 2;
    dp[3] = 4;

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

    i = 0;
    
    while(dp[n] > 0) {
      dp[n]-=3650;
      i++;
    }
    
    cout <<  i  << 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);}
return D;
}

int think(int G,int Z){
int E,F,AL;
E=Z/2;
F=Z%2;
for(int V=0;F+2*V<Z;V++){
AL+=c1(G,E-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<=a;i++){
int x=a-i;
int y=a+3*i;
al+=think(a+1,y);
}

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

return 0;
}

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];	
	}
	

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

	ret 0;
}

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

int method[30];

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

int main() {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) {
            return 0;
        } else {
            cout << (recursion(n) + 1) / 3650 + 1 << endl;
        }
    }
}

// cin: 入力
// cout: 出力
// endl: 改行

C++: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

ll A[31];

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    A[0] = 1;
    rep(i,31) {
        if (i >= 1) A[i] += A[i-1];
        if (i >= 2) A[i] += A[i-2];
        if (i >= 3) A[i] += A[i-3];
    }
    while(true) {
        int N; cin >> N;
        if (N == 0) break;
        ll ans = (A[N] + 3649) / 3650;
        cout << ans << endl;
    }

}

C++: // Kannondou
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
// DP table.
long long dp[31];

int main() {
    
    int N;
    while(true){
    
        cin >> N;
        // 1. input end check.
        if(N == 0) break;
        
        // 2. initialize.
        for(int i = 0; i < 31; ++i) dp[i] = 0;
        dp[0] = 1; // 0段は, 1通り.
        dp[1] = 1; // 1段は, 1通り.
        dp[2] = 2; // 2段は, 1 + 1, 2 の 2通り.
        
        // 3. update DP table.
        for(int i = 3; i < N + 1; ++i) dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
        
        // 4. output answer.
        long long ans = ceil(dp[N] / 10.0 / 365.0);
        cout << ans << endl;
    
    }
    
    return 0;
    
}

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

using namespace std;

long long dp[33];

int main() {
  int n;
  
  while( cin >> n, n ) {
    fill(dp, dp+32, 0);
    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];
    }
    cout << dp[n]/3650+1 << endl;
  }
  
  return 0;
}

C++: #include<iostream>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;

void solve(){
 int n;
  long long a[30] = {1,2,4};
  loop(i,3,30)a[i] = a[i-1] + a[i-2] + a[i-3];
  while(cin>>n,n)
    cout<<1+a[n-1]/3650<<endl;
}
int main(void){
  solve();
  return 0;
}

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

int main() {
  int dp[31];
  dp[0] = dp[1] = 1;
  dp[2] = 2;
  for(int i = 3; i <= 30; i++) {
    dp[i] = dp[i-3] + dp[i-2] + dp[i-1];
    // fprintf(stderr, "dp[%d] = %d\n", i, dp[i]);
  }
  for(int tci = 0; ; tci++) {
    int n; scanf("%d", &n); if(n==0) break;
    printf("%d\n", dp[n]/3650+!!(dp[n]%3650));
  }
  return 0;
}

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

long long int memo[100];

long long int solve(int n){

  if(memo[n]) return memo[n];
  if(n == 1) return 1;
  if(n == 2) return 2;
  if(n == 3) return 4;

  return memo[n] = solve(n-1) + solve(n-2) + solve(n-3);
}

int main(){
  int n;

  solve(35);

  while(cin >> n, n) cout << memo[n]/3650+1 << endl;
}

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

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<iostream>

using namespace std;

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

	for(int n;cin>>n,n;)
		cout<<(tri[n]+3650)/3650<<endl;

	return 0;
}

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

int f(int n){
    if(n == 1) return 1;
    if(n == 2) return 2;
    if(n == 3) return 4;
    
    return f(n-1)+f(n-2)+f(n-3);
}

int main(void){
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        cout << (f(n) / 3650)+1 << endl;
    }
}