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 && n)
	{
		cout << (dp[n] / 3650 + !!(dp[n] / 10 % 365)) << endl;
	}
	return 0;
}

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

using namespace std;

int cost;

void saiki(int n)
{
	
//	cout << n << endl;
	if(n <= 0){
		cost++;
		return;
	}
	if(n > 0){
		if(n-1 >= 0){
			saiki(n-1);
		}
		if(n-2 >= 0){
			saiki(n-2);
		}
		if(n-3 >= 0){
			saiki(n-3);
		}
	}
	/*
	else if(n == 0){
		cost++;
		return;
	}
	*/
}

int main()
{
	for(;;){
		int n, i;
		
		cin >> n;
		if(n == 0){
			break;
		}
		
		saiki(n);
		
		for(i = 1;; i++){
			cost -= 3650;
			if(cost <= 0){
				break;
			}
		}
		
		cout << i << endl;
	}
}

C++: #include<iostream>

using namespace std;

long long memo[100], ans;

int N;

int main() {
	while (true) {
                cin>>N;
                if(N==0){break;}
		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];
		}
		cout << memo[N] / (10 * 365) + 1 << endl;
	}
}

C++: #include <iostream>

using namespace std;

int main()
{
	const int comb[] = { 0, 1, 2, 4, 7, 13, 24, 44, 81, 149, 274, 504, 927, 1705, 3136, 5768, 10609, 19513, 35890, 66012, 121415, 223317, 410744, 755476, 1389537, 2555757, 4700770, 8646064, 15902591, 29249425, 53798080 };

//	cut here before submit 
//	freopen ("testcase.kannondou", "r", stdin );
	int n;

	while (1){
		cin >> n;

		if (n == 0 ){
			break;
		} // end if
		int num = comb[n];

		if (num >= 10 ){
			num = (num / 10) + (num % 10 != 0 ? 1 : 0 );
		} // end if

		int res = num/365 + (num % 365 != 0 ? 1 : 0 );
		cout << res << endl;
	} // end loop

	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <sstream>
using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long

int n;

int a[30];

int main()
{
	a[0] = 1;
	a[1] = 1;
	a[2] = 2;
	FOR(i,3, 31)
	{
		a[i] = a[i - 3] + a[i - 2] + a[i - 1];
	}
	while (1)
	{
		cin >> n; if (!n) return 0;
		if (a[n] % 3650 == 0) cout << a[n] / 3650 << endl;
		else cout << (a[n] /3650) + 1 << endl;
	}
}

C++: #include<iostream>

using namespace std;
int n,a=0;
void check(int x);
int main(void){
    for(;;){
        int z,b,c;
        a=0;
        cin>>n;
        if(n==0)break;
        check(0);
        if(a%10==0)b=a/10;
        else b=1+a/10;
        if(b%365==0)c=b/365;
        else c=1+b/365;

        cout<<c<<endl;
    }


	return 0;
}

void check(int x){

    if(x==n){
        a++;
        return;
    }

    if(x+3<=n)check(x+3);

    if(x+2<=n)check(x+2);

    if(x+1<=n)check(x+1);

}

C++: #include<iostream>
using namespace std;
int a,b,c,d,n,dp[31];
int main(){
  dp[1]=1;
  dp[2]=2;
  dp[3]=4;
  for(int i=4;i<=30;i++){
    dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
  }
  while(1){
    cin>>n;
    if(n==0)break;
    a=dp[n]/10;
    b=dp[n]%10;
    if(b>0)a++;
    c=a/365;
    d=a%365;
    if(d>0)c++;
    cout<<c<<endl;
     
  }
 
  return 0;
}

C++: #include<stdio.h>

int main(void){
	int n;
	while(scanf("%d", &n) && n ){
		
		int dp[100]={0};
		dp[0] = 1;
		
		for(int i = 0; i < n; i++){
			dp[i+3] += dp[i];
			dp[i+2] += dp[i];
			dp[i+1] += dp[i];
		}
		printf("%d\n",dp[n]/3650+1);
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <utility>
#include <set>
#include <cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define all(v) v.begin(),v.end()
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))
using namespace std;
typedef pair<int,int> point;
typedef complex<double> P;
typedef long long ll;

const double eps = 1e-8;
const double INF = 1e12;


double dot(P a,P b){
	return a.real()*b.real()+a.imag()*b.imag();
}
double cross(P a,P b){
	return a.real()*b.imag()-a.imag()*b.real();
}

bool is_orthogonal(P a1,P a2,P b1,P b2){
	return EQ(dot(a1-a2,b1-b2),0.0);
}
bool is_parallel(P a1,P a2,P b1,P b2){
	return EQ(cross(a1-a2,b1-b2),0.0);
}

bool is_point_on_line(P a,P b,P c){
	return EQ(cross(b-a,c-a),0.0);
}

bool is_point_on_linesegment3(P a,P b,P c){
	//|a-c| + |c-b|<=|a-b| ???????????????
	return (abs(a-c)+abs(c-b)<abs(a-b)+EPS);
}

double distance_l_p(P a,P b,P c){
	return abs(cross(b-a,c-a))/abs(b-a);
}


double distance_ls_p(P a,P b,P c){
	if(dot(b-a,c-a)<EPS)return abs(c-a);
	if(dot(a-b,c-b)<EPS)return abs(c-b);
	return abs(cross(b-a,c-a))/abs(b-a);
}

int main(){
	long long dt[50];
	rep(i,50)dt[i]=0;
	dt[1]=1;
	dt[2]=1;
	dt[3]=1;
	rep(i,30){
		dt[i+1]+=dt[i];
		dt[i+2]+=dt[i];
		dt[i+3]+=dt[i];
	}
	int n;
	while(cin>>n,n){
		cout<<dt[n]<<" "<<dt[n]/3650+1<<endl;
	}
	return 0;
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int n;
LL memo[31];

LL solve(int cnt){
	if(cnt >= n) return cnt > n? 0 : memo[cnt] = cnt == n;
	if(memo[cnt] != -1) return memo[cnt];
	LL res1 = solve(cnt + 1);
	LL res2 = solve(cnt + 2);
	LL res3 = solve(cnt + 3);
	return memo[cnt] = res1 + res2 + res3;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	while(1){
		rep(i,31)
			memo[i] = -1;
		cin >> n;
		if(n == 0) break;
		LL ans = solve(0);
		ans = (ans + 10 - 1) / 10;
		ans = (ans + 365 - 1) / 365;
		cout << ans << endl;
	}

	return 0;
}

C++: #include<iostream>

using namespace::std;

int fib(int n) {
	


	int x[100];
	x[0] = 0;
	x[1] = 1;
	x[2] = 2;
	x[3] = 4;

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


int main() {
	/*int n;
	cin >> n;
	int ans;
	int ama;

	ans = n / 3;
	ans = ans * 4;

	if (n % 3 == 1) {
		ans +=
	}
	else if (n % 3 == 2) {

	}*/
	int a[100];
	int i= 0;

	while (true) {
		cin >>a[i];
		if (a[i] == 0)
			break;
		i++;
	}

	for (int j = 0; j < i; j++) {
		if (a[j] != 0) {
			cout << fib(a[j])/10/ 365 + 1 << endl;
		}
		else {
			cout <<0<<endl;
		}
	}

	return 0;

}