Go: package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

func CountPatterns(i int, patternNums []int) int {
	if patternNums[i] != 0 {
		return patternNums[i]
	}
	if i == 0 {
		return 1
	}
	patternNums[i] += CountPatterns(i-1, patternNums)
	if i > 1 {
		patternNums[i] += CountPatterns(i-2, patternNums)
	}
	if i > 2 {
		patternNums[i] += CountPatterns(i-3, patternNums)
	}
	return patternNums[i]
}

func Solve(N int) int {
	patternNums := MakeFilledInts(N+1, 0)
	return (CountPatterns(N, patternNums) + 3649) / 3650
}

func main() {
	for N := scan.Int(); N != 0; N = scan.Int() {
		ans := Solve(N)
		fmt.Println(ans)
	}
}

// --------------------------------------------------------------------------------
// Input

var scan = NewScanner()

type Scanner struct{ *bufio.Scanner }

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(nil, 100000000)
	return &Scanner{sc}
}

func (s *Scanner) String() string {
	s.Scan()
	return s.Text()
}

func (s *Scanner) Strings(l int) []string {
	if l == 0 {
		return []string{}
	}
	sl := make([]string, l, l)
	for i := range sl {
		sl[i] = s.String()
	}
	return sl
}

func (s *Scanner) Int() int {
	n, _ := strconv.Atoi(s.String())
	return n
}

func (s *Scanner) Ints(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func (s *Scanner) Int64() int64 {
	n, _ := strconv.ParseInt(s.String(), 10, 64)
	return n
}

func (s *Scanner) BigInt() *big.Int {
	return big.NewInt(s.Int64())
}

func (s *Scanner) BigInts(l int) []*big.Int {
	if l == 0 {
		return []*big.Int{}
	}
	sl := make([]*big.Int, l, l)
	for i := range sl {
		sl[i] = s.BigInt()
	}
	return sl
}

func (s *Scanner) Float64() float64 {
	f, _ := strconv.ParseFloat(s.String(), 64)
	return f
}

func (s *Scanner) Floats64(l int) []float64 {
	if l == 0 {
		return []float64{}
	}
	sl := make([]float64, l, l)
	for i := range sl {
		sl[i] = s.Float64()
	}
	return sl
}

// --------------------------------------------------------------------------------
// Output

const (
	Yes = "Yes"
	No  = "No"

	YES = "YES"
	NO  = "NO"
)

func PrintBool(v bool, trueStr, falseStr string) {
	if v {
		fmt.Println(trueStr)
	} else {
		fmt.Println(falseStr)
	}
}

// --------------------------------------------------------------------------------
// sort.BigIntSlice

type BigIntSlice []*big.Int

func (sl BigIntSlice) Len() int {
	return len(sl)
}

func (sl BigIntSlice) Less(i, j int) bool {
	return sl[i].Cmp(sl[j]) == -1
}

func (sl BigIntSlice) Swap(i, j int) {
	sl[i], sl[j] = sl[j], sl[i]
}

// --------------------------------------------------------------------------------
// Mint

const (
	Mod = 1000000007
)

type Mint int

func NewMint(value int) Mint {
	return Mint((value%Mod + Mod) % Mod)
}

func (x Mint) Add(y Mint) Mint {
	if v := x + y; v >= Mod {
		return v - Mod
	} else {
		return v
	}
}

func (x Mint) Sub(y Mint) Mint {
	if v := x + Mod - y; v >= Mod {
		return v - Mod
	} else {
		return v
	}
}

func (x Mint) Mul(y Mint) Mint {
	return (x * y) % Mod
}

func (x Mint) pow(n int) Mint {
	if n == 0 {
		return Mint(1)
	}
	a := x.pow(n >> 1)
	a = a.Mul(a)
	if n&1 != 0 {
		a = a.Mul(x)
	}
	return a
}

func (x Mint) Inverse() Mint {
	return x.pow(Mod - 2)
}

func (x Mint) Div(y Mint) Mint {
	return x * y.Inverse()
}

func (x Mint) Neg() Mint {
	return NewMint(int(-x))
}

// --------------------------------------------------------------------------------
// Factorial

type Factorial struct {
	fact        []Mint
	factInverse []Mint
}

func NewFactorial(n int) *Factorial {
	f := new(Factorial)
	f.init(n)
	return f
}

func (f *Factorial) init(n int) {
	fact := make([]Mint, n+1, n+1)
	fact[0] = NewMint(1)
	for i := 1; i <= n; i++ {
		fact[i] = fact[i-1].Mul(NewMint(i))
	}

	inv := make([]Mint, n+1, n+1)
	inv[n] = fact[n].Inverse()
	for i := n; i >= 1; i-- {
		inv[i-1] = inv[i].Mul(NewMint(i))
	}

	f.fact = fact
	f.factInverse = inv
}

func (f *Fa

C++: #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define pb push_back
#define debug(x) cout<< #x <<": "<<x<<endl
#define debug2(x,y) cout<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector< T > >;

int main() {
  vi a(31, 0);
  a[0] = 1;
  a[1] = 1;
  a[2] = 2;
  for (int i = 3; i <= 30; ++i) {
    a[i] = a[i-1]+a[i-2]+a[i-3];
  }
  const int try_per_year = 365*10;
  while (true) {
    int steps;
    cin >> steps;
    if (steps == 0) { break; }
    printf("%d\n", (a[steps]+try_per_year-1)/try_per_year);
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n,memo[50][50];
int solve(int dp,int sum);

int main(){
    while(1){
    cin >> n;
    if(n==0)break;
    cout << (solve(0,0)/(365*10))+1 << endl;
    fill(memo[0],memo[49],0);
    }

return 0;
}

int solve(int dp,int sum){
    if(sum==n)return 1;
    else if(sum>n)return 0;
    if(memo[dp][sum]!=0)return memo[dp][sum];
    return memo[dp][sum]=solve(dp+1,sum+1)+solve(dp+1,sum+2)+solve(dp+1,sum+3);
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
  const int N = 30;
  vector<long long> DP;
  DP.push_back(1);
  for (int i = 1; i <= N; i++) {
    int size = static_cast<int>(DP.size());
    long long var = 0;
    if (i - 3 >= 0) var += DP.at(size - 3);
    if (i - 2 >= 0) var += DP.at(size - 2);
    if (i - 1 >= 0) var += DP.at(size - 1);
    DP.push_back(var);
  }

  long long n;
  cin >> n;
  while (n != 0) {
    long long var = DP.at(n);
    int year = ceil(var / 3650.0);
    cout << year << endl;
    cin >> n;
  }
}

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

int s[31] = {} ;
int ans[31] = {} ;

void cal(){
	s[1] = 1 ;
	s[2] = 2 ;
	s[3] = 4 ;
	
	for( int i=4 ; i<=30 ; i++ ){
		s[i] = s[i-1] + s[i-2] + s[i-3] ;
	}
	
	for( int i=1 ; i<=30 ; i++ ){
		ans[i] = s[i] / 3650 ;
		if( s[i] % 3650 > 0 ) ans[i]++ ;
	}
}

int main(){
	
	cal() ;
	
	int n ;
	
	while( cin >> n , n ){
		cout << ans[n] << endl ;
	}
	
return 0 ;
}

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

int funk(int a,int b){
	int c=0;
	if(a==b){
		return 1;
	}else if(a>b){
		return 0;
	}else{
		c+=funk(a+1,b);
		c+=funk(a+2,b);
		c+=funk(a+3,b);
		return c;
	}
	
}
	
	
int main() {
	int n,aa,year;
	while(1){
	cin >> n;
	if(n==0) break;
	aa=funk(0,n);
	year=aa/3650;
	year+=1;
	cout << year << endl;
	}
	return 0;
}

C++: #include <iostream>

int ways(int n)
{
	if (n==1) return 1;
	else if (n==2) return 2;
	else {
		int* DP = new int[n+1];
		DP[0] = 1; DP[1] = 1; DP[2] = 2;
		for (int i=3; i<=n; i++) {
			DP[i] = DP[i-1] + DP[i-2] + DP[i-3];
		}
		int res = DP[n];
		delete[] DP;
		return res;
	}
}

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n==0) break;
		int w = ways(n);
		int d = w / 10;
		if (w%10>0) d++;
		int y = d / 365;
		if (d%365>0) y++;
		std::cout << y << std::endl;
	}
	return 0;
}