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>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}

typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
long long dp[31] = {1,1,2};
void func(int n){
	for(int i = 3; i < 30; i++){
		dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
	}
}


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

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

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

//a[n]=a[n-1]+a[n-2]+a[n-3]を求める関数

int f(int n){  //再帰関数
    if(n==1) return 1;
    if(n==2) return 2;
    if(n==3) return 4;
    //f(n)=f(n-1)+f(n-2)+f(n+3);
    return f(n-1)+f(n-2)+f(n-3);
}

int main(void){
    while(true){
        int n;
        cin >> n;
        if(n==0)break;
        cout << (f(n)/3650)+1 << endl;
    }
}

C++: #include <iostream>

using namespace std;

int main()
{
    int T[31];
    T[0] = 1;
    T[1] = 1;
    T[2] = T[1]+T[0];
    for (int i=3; i<=30; i++)
        T[i] = T[i-1]+T[i-2]+T[i-3];
    for (int i=0; i<=30; i++)
        T[i] = (T[i]+3650-1)/3650;

    while (true)
    {
        int n;
        cin>>n;
        if (n==0)
            break;
        cout<<T[n]<<endl;
    }
}

C++: #include<stdio.h>
int dp[31];
int main(){
	int n;
	int i,j;
	while(1){
		scanf("%d",&n);
		if(n==0)return 0;
                for(i=0;i<=n;i++)dp[i]=0;
		dp[0]=1;
		for(i=0;i<n;i++){
			for(j=1;j<=3;j++){
				if(i+j<=n)dp[i+j]+=dp[i];
			}
		}
		int ans;
		if(dp[n]%10==0)ans=dp[n]/10;
		else ans=(int)dp[n]/10+1;
		if(ans%365==0)printf("%d\n",ans/365);
		else printf("%d\n",(int)ans/365+1);
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repn(i,n,m) for(int i=n;i<m;i++)
#define repn1(i,n,m) for(int i=n;i<=m;i++)
using namespace std;

int main(){

	int dp[100] = {0};
	int n;
	
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;

	repn(i, 4, 30) dp[i] = dp[i-1] + dp[i-2] + dp[i-3];

	while(cin >> n, n){

		cout << (dp[n] / 10 / 365) + (dp[n]%3650==0 ? 0 : 1) << endl;
	}

	return 0;
}

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

using namespace std;
const static int STEP_NUM = 30;

int main() {
  int dp[ STEP_NUM + 1 ];
  dp[ 0 ] = 1;
  dp[ 1 ] = 1;
  dp[ 2 ] = 1 + dp[ 1 ];
  for( int i = 3; i <= STEP_NUM; i++ ) {
    dp[ i ] = dp[ i - 3 ] + dp[ i - 2 ] + dp[ i - 1 ];
  }
  while( true ) {
    int n;
    cin >> n;
    if( !n ) { return EXIT_SUCCESS; }
    cout << ceil( dp[ n ] / 3650.0 ) << endl;
  }

}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int dp[32] = {0};
    dp[1] = 1;
    dp[2] = 2;
    dp[3] = 4;
    while(cin >> n , n){
        if(n <= 3)
            cout << 1 << endl;
        else{
            for(int i = 4; i <= n; i++)
                dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
            cout << dp[n] / 10 / 365 + 1 << endl;
        }
    }
}

C++: #include <iostream>

const int kMaxJumpStep = 3;

int dp(const int N){
	int step[31];
	step[0] = 1;

	for (int i = 0; i < N; i++){
		for (int j = i + 1; j <= i + kMaxJumpStep; j++){
			if (j > N) break;
			step[j] += step[i];
		}
	}

	return step[N];
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	while (1){
		int n;
		std::cin >> n;
		if (n == 0) break;
		std::cout << dp(n)/3650 + 1 << std::endl;
	}

	return 0;
}

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]/10 + 364)/365 << endl;
		cin >> N;
	}
}

C++: #include<iostream>

using namespace std;

int main(){

	int n;
	int dp[32];
	int ans;

	while(n>0){

		cin >> n;

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

		ans = dp[n] / 3650;
		if(dp[n]%3650 != 0){
			ans++;
		}

		cout << ans << endl;

	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N;
    vector<ll> stairs;
    while (cin >> N) {
        if (N) stairs.push_back(N);
        else break;
    }
    
    // calculation
    REP(i, stairs.size()) {
        ll num_stair = stairs[i];
        
        // dp table
        vector<ll> dp(num_stair+1, 0);
        
        // dp table init
        dp[num_stair] = 1;
        if (num_stair >= 2) dp[num_stair-1] = 1;
        if (num_stair >= 3) dp[num_stair-2] = 2;
        
        for (ll j = num_stair-3; j >= 0; --j) {
            dp[j] = dp[j+1] + dp[j+2] + dp[j+3];
        }
        
        cout << (365 + (dp[0]/10))/365 << "\n";
    }
    
    
    
    return 0;
}

C++: #include <iostream>
#include <vector>
#include<queue>
using namespace std;
#define loop(i,n) for (int i = 0; i < n; i++)
int main()
{
	int n;
	cin >> n;
	vector<long long int> dp(n + 1, 0);
	dp[0] = 0;
	loop(i, n)
	{
		if (i + 1 <= n)dp[i + 1] += dp[i];
		if (i + 2 <= n)dp[i + 2] += dp[i];
		if (i + 3 <= n)dp[i + 3] += dp[i];
	}
	cout << (dp[n] / 10 + 1) / 365 + 1 << endl;
	return 0;
}

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

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

    while(1){
        int n;
        cin >> n;
        if(n == 0)  break;
        int ans = (((dp[n]+9) / 10) + 364) / 365;
        cout << ans << endl;
    }

    return 0;
}