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>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;

int main() {
	ll dp[35] = {};
	dp[0] = 1;
	REP(i, 30) {
		dp[i+1] += dp[i];
		dp[i+2] += dp[i];
		dp[i+3] += dp[i];
	}
	int n;
	while(cin >> n, n)
		cout << dp[n] / 3650 + 1 << endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
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; }
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
const ll INF =1LL << 62;

ll dp[31];
int main(){
	for(int i=0;i<31;i++){
		dp[i]=0;
	}
	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];
	}
	while(1){
		int n;cin >>n;
		if(n==0)break;
		cout << (dp[n]+3649)/3650<< endl;
	}
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int A[31] = { 1,1 };

int a(int n) {
	if (A[n])return A[n];
	if (n - 1 >= 0)A[n] += A[n - 1] ? A[n - 1] : a(n - 1);
	if (n - 2 >= 0)A[n] += A[n - 2] ? A[n - 2] : a(n - 2);
	if (n - 3 >= 0)A[n] += A[n - 3] ? A[n - 3] : a(n - 3);
	return A[n];
}

int main() {
	for (int n; cin >> n&&n;)
		cout << ceil((double)a(n) / (365 * 10)) << 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 <iostream>
using namespace std;
int num(int n);
int main()
{
  int n;
  cin >> n;
  cout << num(num(n)) <<endl;
  return 0;
}

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

C++: #include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}

int main(){
  int n;
  while(true){
    cin >> n;
    if(n == 0)break;
    int dp[n];
    memset(dp, 0, sizeof(dp));

    dp[0] = 1;
    dp[1] = 2;
    dp[2] = 4;
    rep(i,n-3){
      dp[i+3] = dp[i+2] + dp[i+1] + dp[i];
    }
    cout << ceil(ceil(dp[n-1],10), 365) << endl;
  }
}

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

#define rep(i,x) for(int i=0;i<x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rep_to(a,i,x) for(int i=a;i<x;i++)

using namespace std;

int main()
{
	int num[1000]={};
	int add[1000]={};
	int n;
	cin>>n;

	double sum=1;
	rep(i,n)
	{
		if(i<=3)add[i]=i;
		else add[i]+=(add[i-3]+add[i-2]+add[i-1]);
		sum+=add[i];
	}
	cout<<ceil(sum/3650)<<endl;


	return 0;
}

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

int dx[31];

int main(){
	int n;
	dx[1] = 1;
	dx[2] = 2;
	dx[3] = 4;
	for(int i = 4; i <= 30; i++){
		dx[i] = dx[i - 3] + dx[i - 2] + dx[i - 1];
	}
	while(cin >>n){
		if(n == 0) break;
		int day, year;
		day = dx[n] / 10;
		if(dx[n] % 10 != 0) day++;
		year = day / 365;
		if(day % 365 != 0) year++;
		cout <<year <<endl;
	}
	return 0;
}

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

int num(int n);

int main(){
  int n;
  cin>>n;
  cout << num(n)/3650 <<endl;
}

int num(int n){
    switch (n)
    {
        case 1: return 1;
        case 2:  return 2;
        case 3:  return 4;
    }
  return num(n-1)+num(n-2)+num(n-3);
}

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

long long dp[31] = {1,1,2};
int ans[31];
int n;

int main(){
  
  for(int i = 3 ; i < 31 ; i++){
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
  }
  for(int i = 0; i < 31 ; i++){
    ans[i] = dp[i] / 10;
    if(dp[i] % 10 != 0) ans[i]++;
    ans[i] = ans[i] / 365 ;
    if(ans[i] % 365 != 0) ans[i]++;
    if(ans[i] == 0) ans[i]++;
  }

  for(int i = 0; i < 31 ; i++){
    cout << ans[i] << " ";
  }
  cout << endl;
  for(int i = 0; i < 31 ; i++){
    cout << dp[i] << " ";
  }

  while(cin >> n, n != 0){

    cout << ans[n] << endl; 
  }
  
  return 0;
}

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

int main(void)
{
  int n;
  int a[31]={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++: #define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <algorithm>
#include <complex>
#include <cassert>
#include <vector>
#include <iomanip>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    vll dp(35);
    dp[0] = 1;
    rep(i, 35){
        rep(j, 4)if (j){
            if (i - j >= 0){
                dp[i] += dp[i - j];
            }
        }
    }
    int n;
    while (cin >> n && n){
        cout << dp[n] / 10 / 365 + 1<< endl;
    }
}