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

int main()
{
	long long sum[31] = {0};
	
	sum[0] = 1;
	
	for(int i = 1; i < 31; ++i) {
		
		sum[i] = 0;
		if(i - 1 >= 0)
			sum[i] += sum[i - 1];
		if(i - 2 >= 0)
			sum[i] += sum[i - 2];
		if(i - 3 >= 0)
			sum[i] += sum[i - 3];
	}
	
	while(true) {
		
		int n;
		
		scanf("%d", &n);
		if(n == 0)
			break;
		
		printf("%lld\n", (sum[n] - 1LL) / 3650LL + 1LL);
	}
	
	return 0;
}

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

int main()
{
	int n;
	int year;
	while (cin >> n)
	{
		if (n == 0) break;

		int a[30];

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

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

		year = a[n - 1] / 3650;
		if (a[n - 1] % 3650 > 0)
		{
			year += 1;
		}

		cout << year << endl;

	}
	
	return 0;
}

C++: #include <iostream>

int main(int argc, char const* argv[])
{
    int dp[35] = {0};

    int n=1;
    std::cin >> n;


    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 1;

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

    int year = 0;
    year = dp[n-1] / 3650;
    if ((dp[n-1] % 3650) > 0) year +=1;

    std::cout << year << std::endl;
    return 0;
}

C++: void main(){int n,i,ans[64]={0};ans[0]=ans[1]=1;ans[2]=2;for(i=3;i<31;i++)ans[i]=ans[i-1]+ans[i-2]+ans[i-3];for(;;){scanf("%d",&n);if(n==0)break;printf("%d\n",ans[n]/3650+1);}}

C++: /*
	AOJ_0173:Kannondou
*/

#include	<iostream>
#include	<utility>
#include	<algorithm>

using namespace std;

/*prototype declaration*/
long long getPattern(int x);

long long dp[30] = {1, 2, 4};

int main() {
	while(1) {
		int a;
		long long gp;
		
		cin >> a;
		if(a == 0) { break; }
		
		gp = getPattern(a);
		if(gp % 3650 != 0) {
			cout << gp / 3650 + 1 << endl;
		} else {
			cout << gp / 3650 << endl;
		}
	}
	return 0;
}

long long getPattern(int x) {
	if(x < 3) {
		return dp[x-1];
	} else {
		if(dp[x-1] != 0) {
			return dp[x-1];
		} else {
			dp[x-1] = getPattern(x-1) + getPattern(x-2) + getPattern(x-3);
			return dp[x-1];
		}
	}
}

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

#define rep(a, b, c) for (int a = b; a < c; a++)

using namespace std;

int main() {
    while (true) {
        int N;
        cin >> N;

        if (N == 0) break;

        N++;
        long long dp[N];
        dp[0] = 1;

        rep(i, 1, N) {
            dp[i] = dp[i - 1];
            if (i > 1) dp[i] += dp[i - 2];
            if (i > 2) dp[i] += dp[i - 3];
        }
        cout << ceil(ceil(dp[N - 1] / 10.0) / 365.0) << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int n;
  while(true){
    cin >> n;
    if(n == 0){
      break;
    }
    int table[n+4];
    fill(table, table+(n+4), 0);
    table[0] = 1;
    for(int i = 0; i < n; ++i){
      table[i+1] += table[i];
      table[i+2] += table[i];
      table[i+3] += table[i];
    }
    cout << (table[n] / 10 / 365) + 1<< endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
long long dp[30];

void tribonacci(int n){
    if (n==1) {
        dp[n-1] = 1;
    } else if (n==2) {
        dp[n-1] = 2;
    } else if (n==3) {
        dp[n-1] = 4;
    } else {
        dp[n-1] = dp[n-2] + dp[n-3] + dp[n-4];
    }
}

int main() {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) {
        tribonacci(i);
    }
    cout << dp[n-1] << endl;
    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  unsigned long long ary[35] = {0};
  int n; 
  ary[0] = 1; 
  ary[1] = 1;
  ary[2] = 2;
  loop(i,3,35){
    ary[i] = ary[i-1] + ary[i-2] + ary[i-3];
    //  cout<<i<<" "<<ary[i]<<" "<<ary[i]/365<<endl;
  }

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

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

int main() {
    int a[100]={0};
    a[0]=1;
    a[1]=1;
    a[2]=2;
    int n;
    int x;
    while(cin >>n){
    x=0;
    for(int i=3;i<n;i++){
    	a[i]=a[i-3]+a[i-2]+a[i-1];
    }
    x=a[n]/3650;
    x=x+1;
    cout << x;
    
    }
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	unsigned long long dp[100];
	dp[0] = 0;
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;
	rep(i,4,40){
		dp[i] = dp[i-1] + dp[i-2] + dp[i-3];	
	}
	

	int n;
	while( cin >> n ){
		if( !n )
			ret 0;

		if( dp[n] % 3650 )
			cout << dp[n] / 3650 + 1 << endl;
		else
			cout << dp[n] / 3650 << endl;
	}

	ret 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,a[31];

int main(){
	a[1]=1;a[2]=2;a[3]=4;
	for(int i=4;i<31;i++)a[i]=a[i-1]+a[i-2]+a[i-3];
	while(cin>>n){
		if(!n)return 0;
		cout<<(a[n]+3649)/3650<<endl;
	}
}

C++: #include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	unsigned long long dp[100];
	dp[0] = 0;
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;
	rep(i,4,40){
		dp[i] = dp[i-1] + dp[i-2] + dp[i-3];	
		//cout << dp[i] << endl;
	}
	
	int n;
	while( cin >> n ){
		cout << dp[n] / 3650 + 1 << endl;
	}

	ret 0;
}