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

int A[128],N;
int main() {
	A[0] = 1;
	cin >> N;
	while(N != 0) {
		for(int i=0; i<N+1; ++i) {
			if(A[i] ==0) {
				A[i] = A[i-1];
				if(i>1) A[i] += A[i-2];
				if(i>2) A[i] += A[i-3];
			}
		}
		cout << ((A[N]+9)/10 + 364)/365 << endl;
		cin >> N;
	}
}

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


void solve(vector<int>& a) {
    a[0] = 1;
    for(int i = 1; i <= 30; i++) {
        if(i == 1) {
            a[i] = a[i - 1];
        } if(i == 2) {
            a[i] = a[i - 1] + a[i - 2];
        } else {
            a[i] = a[i - 1] + a[i - 2] + a[i - 3];
        }
    }
    for(int i = 1; i <= 30; i++) {
        a[i] = (a[i] + (3650 - 1)) / 3650;
    }
}

int main() {
    vector<int> a(31);
    solve(a);
    vector<int> inpArray;
    int inp;
    do {
        cin >> inp;
        inpArray.push_back(inp);
    } while(inp != 0);

    for(int i = 0; i < (int)inpArray.size() - 1; i++)
        cout << a[inpArray[i]] << endl;

    return 0;
}

C++: include<iostream>

using namespace::std;

int fib(int n) {
	


	int x[100];
	x[0] = 0;
	x[1] = 1;
	x[2] = 2;
	x[3] = 4;

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


int main() {
	
	cin >> n;
	int ans;
	int ama;

	ans = n / 3;
	ans = ans * 4;

	if (n % 3 == 1) {
		ans +=
	}
	else if (n % 3 == 2) {

	}*/
	int a[100];
	int i= 0;

	while (true) {
		cin >>a[i];
		if (a[i] == 0)
			break;
		i++;
	}

	for (int j = 0; j < i; j++) {
		if (a[j] != 0) {
			cout << fib(a[j])/10/ 365 + 1 << endl;
		}
		else {
			cout <<0<<endl;
		}
	}

	return 0;

}

C++: 

#include <algorithm>
#include <iostream>
using namespace std;

int A[128], n; 
int main() {
	while(cin >> n && n >0){
		A[0] = 0;
		A[1] = 1;
		A[2] = 2;
		for (int i=3; i<=n+10; ++i) {
			A[i] = A[i-1]+A[i-2]+A[i-3];
		}
	cout << (A[n]+9/10+364)/365 <<endl;
	}
}

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

#define int long long

int dp[50];
int n;

void init() {
  dp[0] = 1;
  for (int i = 1; i <= 30; i++) {
    for (int j = 1; j <= 3; j++) {
      dp[i+j] += dp[i];
    }
  }
}

signed main() {
  init();
  while (1) {
    cin >> n;
    if (n == 0) break;
    int mult = 3650;
    cout << (dp[n] + mult - 1) / mult << endl;
  }

  return 0;
}

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

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

	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

 
   int ans[31] = {};
  ans[1] = 1;
  ans[2] = 2;
  ans[3] = 4;
  for(int i=4;i<=30;i++) ans[i] = ans[i-3] + ans[i-2] + ans[i-1] ;
     
 while(1) {
				
   int n;
   cin >> n;
   if(n == 0) break;
   
    cout << (ans[n]/3650) +1 << endl;

  }

  return 0;

}

C++: void main()
{
	int n,i;
	int 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++: #include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

int dp[40];

int solve(int n){
	memset (dp, 0, sizeof(dp));
	
	dp[0] = 1;
	rep(i,n){
		dp[i+1] += dp[i];
		dp[i+2] += dp[i];
		dp[i+3] += dp[i];
	}
	return dp[n];
	
	}
	
int main(){
	while(true){
		int n=0;
		scanf("%d", &n);
		
		if(!n) break;
		
	
	
	
		printf("%d\n", (int)ceil((double) solve(n)/10/365));
		
	}
		return 0;
		
		
	}

C++: #include <iostream>
using namespace std;
/*
x?????????????????????????????????calc(x)
calc(0) = 1
calc(i) = calc(i - 1) * calc(i - 2) + calc(i - 3)
*/
int answer[30] = {};

int calc(int n) {
	for (int i = 0; i <= n; i++) {
		if (i == 0) answer[i] = 1;
		else if (i == 1) answer[i] = 1;
		else if (i == 2) answer[i] = 2;
		else answer[i] = answer[i - 1] + answer[i - 2] + answer[i - 3];
	}
	return (answer[n] / 3650) + ((answer[n] % 3650 > 0) ? 1 : 0);
}

int main() {
	int n;
	while (true) {
		cin >> n;
		if (n == 0) return 0;
		cout << calc(n) << endl; 
	}
}

C++: #include <iostream>

using namespace std;

int dp[32];
void DPCalc()
{
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	for(int i = 0; i < 28; ++i)
	{
		dp[i + 3] = dp[i] + dp[i + 1] + dp[i + 2];
	}
}

void solve()
{
	DPCalc();
	int n;
	while(cin >> n)
	{
		if(n == 0)
		{
			break;
		}
		int ans = dp[n] / 365 / 10;
		if(dp[n] % 365)
		{
			++ans;
		}
		cout << ans << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<iostream>

using namespace std;

int main() {
    long long n[50], p;

	n[0] = 1; 
    n[1] = 1; 
    n[2] = 2;

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

	while (1) {
		cin >> p;
		if (p == 0){
            break; 
        }
        
		cout << (n[p] + 3649) / 3650 << endl;
	}
}

C++: #include<iostream>
#include<vector>
#include<cstdio>
#include<map>
#include<queue>

using namespace std;

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

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

int func(int n, int m){
	if(m==n)return 1;
	else if(m>n)return 0;
	else{
		int cnt=0;
		for(int i=1;i<=3;++i){
			cnt += func(n,m+i);
		}
		return cnt;
	}
}


int main(){
	int n;
	while(cin>>n,n){
		cout << func(n,0)/10/365+1 << endl;
		
		
	}
	
	
	
	
}

C++: #include <iostream>

using namespace std;

int dp[31];

int main()
{
  int n;

  while (1) {
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < sizeof(dp) / sizeof(int); i++) {
      dp[i] = 0;
    }

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

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

    int day = (dp[n] + 9) / 10;
    int year = (day + 364) / 365;

    cout << year << endl;
  }
}

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

#define dbg if(0)
using namespace std;
#define ll long long

int main(){
    int n;
    int stair[30+1];
    for(int i=0;i<=30;i++){
        stair[i]=0;
    }
    stair[0]=1;
    for(int i=0;i<=30;i++){
        if(i>0)stair[i]+=stair[i-1];
        if(i>1)stair[i]+=stair[i-2];
        if(i>2)stair[i]+=stair[i-3];
    }
    while(1){
        cin >> n;
        if (n==0)break;
        int ans=(stair[n]/10+364)/365;
        if (ans==0)ans++;
        cout <<ans<<endl;
    }

    return 0;
}