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 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(cin>>n){

		cin>>n;

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

	}
}

C++: #include <iostream>
#include <cmath>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main(){
	int n;
	int dp[32] = {};
	dp[0] = dp[1] = 1;
	dp[2] = 2;
	rep2(i,3,32) {
		dp[i] = dp[i-3] + dp[i-2] + dp[i-1];
	}
	rep(i,32) {
		cout << dp[i] << endl;
	}
	while(cin >> n, n) {
		cout << ceil(dp[n] / 3650.0) << endl;
	}
    return 0;
}

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

using namespace std;


int main()
{
	int t[31 + 3];
	t[0] = t[1] = 0;
	t[2] = 1;
	for (int i = 3; i < 31 + 3; ++i)
		t[i] = t[i-1] + t[i-2] + t[i-3];

	int n;
	while (scanf("%d", &n), n)
		printf("%d\n", (t[n+2]/10+364) / 365);

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  long long fibo[31]={0,1,2,4};
  for(int i=4;i<=30;i++){
    fibo[i] = fibo[i-2]+fibo[i-1]+fibo[i-3];
  }
  int n;
  while(cin >> n,n){
    cout << (fibo[n]%3650?fibo[n]/3650+1:fibo[n]/3650) << endl;
  }
}

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

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

typedef long long ll;

int main() {
	int n;
	while (cin >> n, n) {
		vector<ll> dp(n + 1, 0);
		dp[0] = 1;
		REP(i, n) {
			FOR(j, 1, 3 + 1) {
				if (i + j > n) continue;
				dp[i + j] += dp[i];
			}
		}
		dp[n] = dp[n] % 10 == 0 ? dp[n] / 10 : dp[n] / 10 + 1;
		cout << (dp[n] % 365 == 0 ? dp[n] / 365 : dp[n] / 365 + 1) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    // DP テーブル
    long long dp[100010];

    // 入力
    int a;
    while(cin>>a, a){  
        // 初期化 
        long long dp[100010];
        rep(i,100010) {
            dp[i] = INF;
        }

        // 初期条件
        dp[0] = 1;   

        // ループ
        rep2(i,a+1) {
            if (i > 2) {
                if(dp[i] !=  0) {
                    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
                }
            }
            else if (i > 1){
                if(dp[i] !=  0) dp[i] = dp[i-1] + dp[i-2];
            }
            else {
                dp[i] = dp[i-1];
            }
        } 
        cout << ((dp[a] + 9)/10 + 364)/365 << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
 
int main(){
while(1){
int a;
cin>>a;
if(a==0) break;
int dp[33];
dp[0]=1;
dp[1]=1;
dp[2]=2;
if(a<3){
 cout<<1<<endl;
continue;
}
else{
for(int j=3;j<=a;j++){
dp[j]=dp[j-1]+dp[j-2]+dp[j-3];
}
if(dp[a]%10==0) dp[a]/=10;
else dp[a]=(dp[a]+10)/10;
if(dp[a]%365==0) dp[a]/=365;
else dp[a]=(dp[a]+365)/365;
cout<<dp[a]<<endl;
}
}
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<string.h>

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



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

C++: #include<iostream>
using namespace std;
int main(){
  int ans[31]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,3,6,10,19,34,62,113,207,381,701,1288,2369,4357,8014,14740}
  while(1){
    cin>>ans[0];
    if(!ans[0])
      return 0;
    cout<<ans[ans[0]];
  }
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int main()
{
	while ( true )
	{
		int n;
		cin >> n;

		if ( n == 0 )
		{
			break;
		}

		VI dp( n + 1 );
		dp[0] = 1;

		REP( i, 1, dp.size() )
		{
			REP( j, 1, 4 )
			{
				if ( 0 <= i - j )
				{
					dp[i] += dp[ i - j ];
				}
			}
		}

		cout << dp.back() / 3650 + 1 << endl;
	}

	return 0;
}

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

C++: #include <iostream>

#define MAX_N 32
#define INF -1

int ans, n;
long memo[MAX_N];

inline
void solve();

long dp(int a);

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

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

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

inline
int answer(int in){
    return in % 3650 > 0 ? in / 3650 + 1 : in / 3650;
}

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(cin>>n){
		cout<<dfs(n,0) / 10 / 365 + 1<<endl;
	}
}