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++: #define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

		vector<ll> dp(n + 1);
		dp.at(0) = 1;

		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= 3; j++)
			{
				if (i - j >= 0)
				{
					dp.at(i) = (dp.at(i) + dp.at(i - j));
				}
			}
		}

		cout << (dp.at(n) + 3650 + 1) / 3650 << endl;
	}

}

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

int dp[40];

int main(){
    dp[0] = 1;
    for(int x = 0; x <= 30; x++){
        dp[x+1] += dp[x];
        dp[x+2] += dp[x];
        dp[x+3] += dp[x];
    }
    int n;
    while( scanf(" %d", &n), n ){
        printf("%d\n", (int)ceil(dp[n]/3650.0));
    }
    return 0;
}

C++: #include<cstdio>
#include<cmath>
#include<algorithm>


using namespace std;

int main(void){
    int n;
    while(scanf("%d", &n),n){
        int dp[64] ={0};
        dp[0] = 1;
        for(int i = 0; i <= n; i++){
            for(int j = 1; j < 4; j++){
                if(i - j >= 0){
                    dp[i] += dp[i-j];
                }
            }
        }
        printf("%d\n", dp[n]/3650 + 1);


    }

    return 0;
}

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

int num(int n);

int main()
{
  string s;
  cin >> s;
  int n = std::stoi;
  cout << num(n) <<endl;
}

int num(int n){
  if(n<0)return 0;
  return num(n-1)+num(n-2)+num(n-3);
}

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

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define each(c,itr) for(auto itr=(c).begin();itr!=(c).end();itr++)

template<class T> void pv(T& a) { for (auto i : a) cout << i << ' '; cout << endl; }

int main() {
  int N;
  int dp[40];

  while(1) {
    cin >> N;
    if (N == 0) break;

    rep(i,40) dp[i] = 0;

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

    // pv(dp);
    cout << ceil(dp[N] / 3650.0) << endl;
  }

  return 0;
}

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

int main() 
{
	while (1) 
	{
		int a;
		cin >> a;
		if (a == 0)break;
		if (a == 1 || a == 2 || a == 3) { cout << 1 << endl; continue; }
		vector<int>s(4);
		s[0] = 1; s[1] = 2; s[2] = 4;
		for (int c = 0; c < a - 3; c++) {
			s[3] = s[2] + s[1] + s[0];
			s[0] = s[1];
			s[1] = s[2];
			s[2] = s[3];
		}
		cout << s[2] /3650+1 << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
  int n;
  int dp[31];
  int ans;
  dp[0] = dp[1] = 1;
  dp[2] = 2;
  while(cin >> n,n){
    
    for(int i = 2 ; i < n ; i++){
      dp[i + 1] = dp[i] + dp[ i - 1] + dp[i - 2];
    }
    ans = dp[n]/3650 + 1;
    
    cout << ans << endl;
    
  }
  return 0;
}

C++: /*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}







/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a;
  vector<ll> dp(31,0);
  dp[0]=1;
  dp[1]=dp[0];
  dp[2]=dp[0]+dp[1];
  for(ll i=3;i<=30;i++){
    dp[i]=dp[i-3]+dp[i-2]+dp[i-1];
  }
  while(cin>>a){
    if(!(a==0)) cout<<(((dp[a]+9)/10)+364)/365<<endl;
  }
}

C++: #include <algorithm>
#include <iostream>
using namespace std;
int A[128], N;
int main(){
    while(cin >> N, N){
        A[0] = 1;
        for (int i=1; i<=N; ++i){
            A[i] = A[i-1];
            if(i >= 2) A[i] += A[i-2];
            if(i >= 3) A[i] += A[i-3];
        }
        cout << ((A[N]+9)/10 + 364)/365 << endl;
    }
}

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

int main(){
	int n;
	int ans =0;
	int i = 4;
	int check[3] = { 1, 2, 4 };

	cin >> n;

	switch (n){
	case 1:
		ans = 1;
		break;
	case 2:
		ans = 2;
		break;
	case 3:
		ans = 4;
		break;
	default :
		while (n >= i){
			ans = check[0] + check[1] + check[2];
			i++;
			check[0] = check[1];
			check[1] = check[2];
			check[2] = ans;
		}
	}

	cout << ans << endl;

	return 0;
}

C++: #include "stdio.h"

#define max(a,b) (a) > (b) ? (a) : (b)

int n;
long long int dp[31] = {};//i段目におけるパターン

long long int ans = 0;

int main(){

	while(1){

		scanf("%d",&n);

		if(n==0) break;

		ans = 0;

		for(int i=0;i<=n;i++){
			dp[i] = 0;	
		}

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

		printf("%d\n",(int)(dp[n]/3650) + 1);

	}

	return 0;
}

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

int main(void){
    int n,dp[MAX+1];
    dp[0] = 0; dp[1] = 1; dp[2] = 2; dp[3] = 4;
    
    for(int i = 4 ; i < MAX+1 ; i++) dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
    while(1){
        cin >> n;
        if(!n) break;
        
        cout << dp[n]/10/365+1 << endl;
    }
    
    return 0;
}