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 <cstdio>
using namespace std;

int main(void)
{
  int n;
  int a[30]={0};

  a[0] = 1, a[1] = 1, a[2] = 2;
  

  /* a[i] Í@iiÚÉ©©éêÌ */
  for(int i = 3 ; i < 30 ; i++)
    {
      a[i] = a[i-1] + a[i-2] + a[i-3];
    }
  
  while(cin >> n)
    {
      if(n == 0) break;
      cout << (a[n] / 10 / 365 + 1) << endl;
      // êúPOÅÁÄANÈÌÅRUTÅéBPúÅàêNvZÈÌÅPð«·
    }
  return 0;
}

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

using namespace std;

struct Memo
{

  int count;

  Memo()
  {
    count = 0;
  }

};

Memo memo[30][3];

int ProgressNumberOfYears(int step_num, int step_kind)
{

  int kind_count = 0;

  if(step_num == 0) return 1;
  else if(memo[step_num - 1][step_kind - 1].count) return memo[step_num][step_kind].count;

  if(step_num - 3 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 3,3);
  if(step_num - 2 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 2,2);
  if(step_num - 1 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 1,1);

  memo[step_num - 1][step_kind - 1].count = kind_count;

  return kind_count;

}

int main()
{

  int step_num;

  while(cin >> step_num && step_num != 0) cout << ProgressNumberOfYears(step_num,0)/10/365 + 1<< endl;

  return 0;

}

C++: //
// AOJ0168　
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168
//  implementation-1: 配るDP
//

#include <iostream>
using namespace std;

const long long INF = 1LL << 60;
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; }

const int iMax=30+3;
long long dp[iMax];

long long calc(int n) {
	for(int i=0; i<iMax; i++) dp[i]=0;
	dp[0]=1;
	
	for(int i=0; i<=n; i++) {
		dp[i+1] = dp[i+1] + dp[i];
		dp[i+2] = dp[i+2] + dp[i];
		dp[i+3] = dp[i+3] + dp[i];
	}
	
	return dp[n];
}


int main() {
	int N=1;
	while (N!=0) {
		cin >> N;
		if (N==0) break;
		long long ans = calc(N);
		ans = (ans-1)/3650 +1;
		cout << ans << 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(){
    while(true){
        int n;
        cin >> n;
        if(n==0) break;
        cout << (f(n) / 3650)+1 << endl;
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int dp[31][4] = {};
  dp[1][1] = 1;
  dp[2][1] = dp[2][2] = 1;
  dp[3][1] = 2;
  dp[3][2] = dp[3][3] = 1;
  for(int i=4;i<31;++i){
    for(int j=1;j<4;++j){
      dp[i][j] += dp[i-j][1] + dp[i-j][2] + dp[i-j][3]; 
    }
  }
  while(cin>>n, n){
    int ans=0;
    for(int i=1;i<4;++i)
      ans += dp[n][i];
    ans = (ans+9)/10;
    ans = (ans+364)/365;
    cout<<ans<<endl;
  }
  return 0;
}

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

using namespace std;

struct Memo
{

  int count;

  Memo()
  {
    count = 0;
  }

};

Memo memo[31][4];

int ProgressNumberOfYears(int step_num, int step_kind)
{

  int kind_count = 0;

  if(step_num == 0) return 1;
  else if(memo[step_num][step_kind].count) return memo[step_num][step_kind].count;

  if(step_num - 3 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 3,3);
  if(step_num - 2 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 2,2);
  if(step_num - 1 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 1,1);

  memo[step_num][step_kind].count = kind_count;

  return kind_count;

}

int main()
{

  int step_num;

  while(cin >> step_num && step_num != 0) cout << ProgressNumberOfYears(step_num,0)/10/365 + 1<< endl;

  return 0;

}

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


int main()
{
	while (true)
	{
		int ary[40];
		int n;
		cin >> n;
		if (n == 0) return 0;

		ary[0] = 1;
		ary[1] = 1;
		ary[2] = 2;
		for (int i = 3; i < n + 1; i++)
		{
			ary[i] = ary[i - 1] + ary[i - 2] + ary[i - 3];
		}

		cout << (ary[n] / 3650) + 1 << endl;
	}

	return 0;
}

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

using ll = long long;

ll dp[50]; // dp[i]: i段目まで上り方の種類

void init() {
   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];
   }
}

int main() {
   init();
   while (1) {
      int n;
      cin >> n;
      if (!n) break;
      ll day = max(1LL, dp[n] / 10);
      cout << day / 365 + (day%365 != 0) << endl;
   }

   return 0;
}

C++: #include <iostream>

using namespace std;
typedef long long ll;

ll memo[40];

ll calc(int n){
    if(memo[n] != -1) return memo[n];
    ll retval = 0;
    for(int i=1;i<=3;i++){
        retval += calc(n-i);
    }
    return memo[n] = retval;
}

int main(){
    for(int i=0;i<40;i++){
        memo[i] = -1;
    }
    memo[1] = 1;
    memo[2] = 2;
    memo[3] = 4;
    calc(30);

    int n;
    while(cin>>n && n != 0){
        cout << calc(n) / 3650 + 1 << endl;
    }
    return 0;
}

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

int main() {
  long long dp[30];
  dp[0] = 1;
  dp[1] = 2;
  dp[2] = 4;
  for (int i = 3; i < 30; i++) {
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
  }
  int a[30];
  for (int i = 0; i < 30; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      break;
    }
    else {
      int x = a[i];
      long long y = dp[x-1]/3650+1;
      cout << y << endl;
    }
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
const long long INF=1LL << 60;



int main() {
    vector<int> dan;
    vector<long long> dp(35,0);
    int N;
    for(int i=0;i<35;i++){
        int tmp;
        cin>>tmp;
        if(tmp==0) break;
        dan.push_back(tmp);        
    }
    dp[0]=1;
    for(int i=1;i<31;i++){
        dp[i]+=dp[i-1];
        if(i>1)dp[i]+=dp[i-2];
        if(i>2)dp[i]+=dp[i-3];
    }
    for(int i:dan){
        cout << dp[i]/10/365+1<<endl;

    }

    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  cout << num(n) <<endl;
  return 0;
}

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

C++: #include <bits/stdc++.h>

using namespace std;

bool Memo[32] = {1,1,1};
int Trib[32] = {0,1,1};
int trib(int num){
	for(int i = 3;i <= num+1;i++){
		if(Memo[i])continue;
		Trib[i] = Trib[i-1] + Trib[i-2] + Trib[i-3];
		Memo[i] = 1;
	}
	return Trib[num+1];
}

int main(){
	int n;
	int ans; 
	while(cin >> n,n){
		ans = trib(n);
		if(ans % 10 % 365  == 0){
			ans = ans/10/365;
		}else{
			ans = ans/10/365+1;
		}
		cout << ans << endl;
	}	
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){

	int n;

	int memo[100];

	while(1){

		cin>>n;

		if(n==0) break;

		memo[0]=1;
		memo[1]=1;
		memo[2]=2;
		for(int i=3;i<=n;i++){
			memo[i]=memo[i-1]+memo[i-2]+memo[i-3];
		}
		cout<<memo[n]/365/10+1<<endl;
	}
}

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

int func(int kaidan,int now){
	int a=0,b=0,c=0;
	
	if(now==kaidan){
		return 1;
	}else if(now>kaidan){
		return 0;
		}else{
		a+=func(kaidan,now+1);
		b+=func(kaidan,now+2);	
		c+=func(kaidan,now+3);
		}
	
	return a+b+c;
	
}

int main(){
	int n,ans;

	while(cin>>n){
		if(n==0)break;
		ans=func(n,0);
		cout<<ans/10/365+1<<endl;
		
		
		
	}
	
	
	return 0;
}