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 cnt;
int dp[100][100];

void rec(int left){
    if (left < 0){
        return;
    }
    if (left == 0){
        cnt++;
        return;
    }

    rec(left-1);
    rec(left-2);
    rec(left-3);

}

int main(int argc, char const *argv[]){
    int n;

    while (cin>>n, n){
        int ans = 0;
        rec(n);
        ans = cnt / 3650;
        cout<<ans+1<<endl;       
    }

    return 0;
}

C++: #include<iostream>

int dp[30];//段数ー１

int main(){
	int n;
	while(std::cin>>n,n){
		memset(dp,0,sizeof(dp));
		dp[0]=1;
		dp[1]=2;
		dp[2]=4;
		for(int i=3;i<n;i++){
			dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
		}
		if(dp[n-1]%365==0)std::cout<<dp[n-1]/3650<<std::endl;
		else std::cout<<dp[n-1]/3650+1<<std::endl;
	}
	return 0;
}

C++: #include<iostream>

int dp[30];//段数ー１

int main(){
	int n;
	while(std::cin>>n,n){
		for(int i=0;i<30;i++)dp[i]=0;
		dp[0]=1;
		dp[1]=2;
		dp[2]=4;
		for(int i=3;i<n;i++){
			dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
		}
		if(dp[n-1]%365==0)std::cout<<dp[n-1]/3650<<std::endl;
		else std::cout<<dp[n-1]/3650+1<<std::endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int dp[31], n, i, result[100];

int main()
{	
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;

	for (int a = 3; a < 30; a++)
	{
		dp[a] = dp[a - 1] + dp[a - 2] + dp[a - 3];
	}

	for (;; i++)
	{
		cin >> n;
		if (n == 0)
		{
			break;
		}
		result[i] = dp[n] / 3650 + 1;
	}

	for (int a = 0; a < i; a++)
	{
		cout << result[a] << endl;
	}


	return 0;
}

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

long int factorial ( int x )
{
  if ( x == 0 ) return 1;
  return x * factorial( x-1 );
}

int main()
{
  while (true)
  {
    int n;      //  段数
    cin >> n;
    if ( n == 0 ) break;

    long int pattern = 0;

    for (int a=0; a <= n/3; a++)
    {
      for (int b=0; b <= n/2; b++)
      {
        for (int c=0; c <=n; c++)
        {
          if ( 3*a + 2*b + c == n )
          {
            pattern += factorial( a+b+c ) / 
              ( factorial(a) * factorial(b) * factorial(c) );
          }
        }
      }
    }

    long int day = pattern / 10 + ( pattern%10 == 0 ? 0 : 1 );
    long int year = day / 365 + ( day%365 == 0 ? 0 : 1 );
    cout << year << endl;
  }
}

C++: //Kannondou
#include <cstdio>
#include <vector>
using namespace std;
int main(){
	int n;
	vector<long long int> step;	step.push_back(1);
	refrain:
	scanf("%d",&n);
	if(n==0)	return 0;
	for(int i=step.size();i<=n;i++){
		step.push_back(0);
		for(int j=1;j<=i&&j<=3;j++)	step[i]+=step[i-j];
	}
	long long int ans=(step[n]+9)/10;
	ans=(ans+364)/365;
	printf("%lld\n",ans);
	goto refrain;
}

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

using namespace std;

#define llong long long 
unsigned llong int n;
int memo[31][16][11];

unsigned llong int solve(int first, int second, int third, int sum){
	if(memo[first][second][third] != -1) return memo[first][second][third];
	if(sum == n){
		return memo[first][second][third] = 1;
	}
	if(sum > n) return memo[first][second][third] = 0;

	unsigned llong int ret = 0;
	for(int i = 1; i < 4; i++){
		if(i == 1) ret += solve(first + 1, second, third, sum + i);
		if(i == 2) ret += solve(first, second + 1, third, sum + i);
		if(i == 3) ret += solve(first, second, third + 1, sum + i);
	}

	return memo[first][second][third] = ret;
}

int main(){
	while(cin >> n, n){
		fill_n(**memo, 31 * 16 * 11, -1);
		unsigned llong int ans = solve(0,0,0,0);
		if(ans % 3650 == 0){
			cout << ans / 3650 << endl;
		}else{
			cout << ans / 3650 + 1 << endl;
		}
	}
	return 0;
}

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

int main() {
  int dan;
  while (cin >> dan && dan>0) {
    int array[dan];
    for (int i=0;i<dan;++i) {
      if (i==0)
	array[i] = 1;
      else if (i==1)
	array[i] = array[i-1];
      else if (i==2)
	array[i] = array[i-1]+array[i-2];
      else
	array[i] = array[i-1]+array[i-2]+array[i-3];
    }
    cout << array[dan-1] << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
      int tmp;
      int dp[100];
      cin>> tmp;
      do{
            fill(dp,dp+100,0);
            dp[0] = 1;
            for (int i = 0; i<tmp;i++)
            {
                  for(int j = 1;j < 4;j++)
                        dp[i+j] += dp[i];
            }
            cout << dp[tmp]/3650 + 1<<endl;
            cin >> tmp;
      }while(tmp);

}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int dp[32], n;
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;

	for(int i = 3; i < 31; i++)
	{
		dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
	}

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

C++: #include<iostream>

using namespace std;

int main()
{
  int n;
  long long int dp[31]={1,1,2};
  for(int i=3;i<30;i++)
      dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
  for(;cin>>n,n;)
    cout<<(long long int)((dp[n]/3650.0)+0.999999)<<endl;
}

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

int main() {
    int n;
    while (cin >> n, n) {
        vector<long long int> v(n + 1);
        v[0] = 1L;
        for (int i = 0; i < n; i++) {
            for (int j = 1; j <= 3; j++) {
                if(i + j <= n)
                    v[i + j] += v[i];
            }
        }
        cout << (v[n] + 3649L) / 3650L << endl;
    }

    return 0;
}

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

int main(void){

	int n; 
	while (cin >> n, n){
		vector<int> dp(n + 5);

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


		cout << (((dp[n] + 9) / 10) + 364) / 365 << endl;

	}


	return 0;
}

C++: #include <vector>
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
    vector<long long> N(30);
    for (int i = 0; i < 30; i++) cin >> N[i];
    for (int i = 0; i < 30; i++) {
        if (N[i] == 0) break;

        vector<long long> dp(31);
        for (int j = 0; j < N[i]; j++) dp[j] = 0;
        dp[0] = 1;
        for (int j = 1; j <= N[i]; j++) {
            dp[j] += dp[j - 1];
            if (j >= 2) dp[j] += dp[j - 2];
            if (j >= 3) dp[j] += dp[j - 3];
        }
        cout << (((dp[N[i]] + 9) / 10) + 364) / 365 << endl;
    }
}

C++: #include <iostream>
using namespace std;
VI memo;
int f(int n){
    if(n<0)
        return 0;
    if(n==0)
        return 1;
    if ( memo[n]!= -1 )
        return memo[n];
    return f(n-1)+f(n-2)+f(n-3);
}
 
int main(){
    int n;
    memo.resize(31,-1);
    while(1){
        cin >> n;
        if(n==0)
            break;
        int num=f(n);
        cout <<num/10/365+1<< endl;
    }
    return 0;  
}