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 A[100];
int n;
int main () {
  while (cin >> n && n) {
    for (int i=3; i<n+1; ++i) {
      A[0] = 1;
      A[1] = 1;
      A[2] = 2;
      A[i] = A[i-1] + A[i-2] + A[i-3];
    }
    if (n == 1) {
      cout << 1 << endl;
    } else { cout << (((A[n-1] + A[n-2] + A[n-3])/3650) + 1) << endl;
    }
  }
}

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

#define YEAR 365
#define SNUM 3
#define MAXK 30

int main(void){
	int kaidan[MAXK];
	int knum;
	int kyear;

	while(1){
		//init
		for(int i=SNUM; i<MAXK; i++)
			kaidan[i]=0;
		for(int i=0; i<SNUM; i++)
			kaidan[i]=1;
		//in
		cin >> knum;
		if(knum==0)break;

		//calc
		for(int i=0; i<knum; i++){
			for(int k=1; k<=SNUM&&k+i<knum; k++)
				kaidan[i+k] = kaidan[i+k] + kaidan[i];
		}
		kyear = kaidan[knum-1] / (365*10) + 1;

		//out
		cout << kyear << endl;
	}

	return 0;
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int dp[100];
	dp[0] = 1;
	dp[1] = 2;
	dp[2] = 4;
	
	REP(i,3,30)
	{
		dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
	}

	int n;
	while(cin >> n && n)
	{
		cout << (dp[n-1]/10/365) + 1 << endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int p[100];

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

	int n;
	while(cin >> n, n){Q
		cout << p[n]/3650+1 << endl;
	}

	return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector<double> vd;
typedef std::vector<std::string> vs;
typedef std::vector<pii> vpii;
typedef std::vector<vi> vvi;
typedef std::vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  vi dp(31);
  dp[0] = dp[1] = 1;
  dp[2] = 2;
  loop(i, 3, dp.size()) dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
  int n;
  while (cin >> n, n) cout << (dp[n] + 3659) / 3650 << endl;
}

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

unsigned int get_answer ( const int n ) {
	if(n <= 2) return 1;
	unsigned int now, pre1 = 2, pre2 = 1, pre3 = 1;

	for ( int i = 3; i <= n; i++ ) {
		now = pre1 + pre2 + pre3;
		pre3 = pre2;
		pre2 = pre1;
		pre1 = now;
	}

	return now / (365 * 10) + 1;
}

int main(void){
	int n;

	while ( cin>>n && n ) {
		cout << get_answer(n) << endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

long dp[31];

int main(){
  fill(dp, dp+31, 0);
  dp[0]=1;
  for(int i=1; i<=30; i++){
    for(int j=1; j<=3; j++){
      if(i-j>=0) dp[i] += dp[i-j];
    }
  }
  int n;
  while(cin>>n, n){
    long res = ((dp[n]/10)+364)/365;
    cout<<res<<endl;
  }

  return 0;
}

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

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

  while (true) {
    cin >> n;
    if (n == 0) return 0;
    cout << a[n] / 10 / 365 + 1 << endl;
  }
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int main() {
  int a, kai[31];
  kai[0] = 1;
  kai[1] = 1;
  kai[2] = 2;
  for (int i = 3; i < 31; i++) {
    kai[i] = kai[i - 1] + kai[i - 2] + kai[i - 3];
  }
  rep(i, 30) kai[i] = (kai[i] + 1) / 3650 + 1;
  while (cin >> a, a)
    cout << kai[a] << endl;
  return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

const int MAX_N = 30;
int n;
int dp[MAX_N+1];

int main()
{
  dp[1]=1;  dp[2]=2;  dp[3]=4;
  erep(i, 4, MAX_N) dp[i] = dp[i-3] + dp[i-2] + dp[i-1];

  while((cin >> n) && n){
    cout << dp[n] / 3650 + (dp[n]%3650 ? 1 : 0) << endl;
  }

  return 0;
}

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

using namespace std;

int main(void){

  int n,a[31];

  fill(a,a+31,0);
  a[0]=a[1]=1,a[2]=2;

  for(int i=3;i<31;i++)
    for(int j=1;j<4;j++)
      a[i]+=a[i-j];
  
  while(cin >> n,n){
    int m=!(a[n]%365>0)?:1;
    cout << a[n]/3650+m << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

template<class T>
bool chmin(T &a, T b)
{
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

long long dp[31];

int main()
{
    for(int i = 0; i < 31; i++){
        dp[i] = 0;
    }
    
    while(true){
        dp[0] = 1;
        dp[1] = 1;
        dp[2] = 2;
        int tmp;
        cin >> tmp;
        if(tmp == 0) break;
        for(int i = 3; i <= tmp; i++){
            dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
        }
        cout << (dp[tmp]-1)/10/365+1 << endl;
        for(int i = 0; i < 31; i++){
            dp[i] = 0;
        }
    }
}