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 <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;
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;}

const int MAX_N = 10 + 3;

int main() {
  vector<ll> dp(MAX_N, 0);
  dp[0] = 1;
  dp[1] = 2;
  dp[2] = 4;
  for (int i=3; i<30; ++i) {
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
    //    printf("[*] dp[%d] = %lld\n", i, dp[i]);
  }
  
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    cout << (dp[n-1] + 3650 - 1) / 3650 << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;

const int MX=40,INF=1001001001,mod=1e9+7;
int dp[MX];

int main(){
    while(1){
        int n;
        cin>>n;
        if(n==0)break;
        rep(i,MX)dp[i]=0;
        dp[0]=1;
        rep(i,n){
            dp[i+1]+=dp[i];
            dp[i+2]+=dp[i];
            dp[i+3]+=dp[i];
        }
        int day;
        if(dp[n]%10==0)day=dp[n]/10;
        else day=dp[n]/10+1;
        int year;
        if(day%365==0)year=day/365;
        else year=day/365+1;
        cout<<year<<endl;
    }
}

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

int main(){
        long long n;
        vector<long long> dp(31);
        for(int i = 0; i < 31; i++){
                if(i == 0) dp[i] = 1;
                else if(i == 1) dp[i] = dp[i - 1];
                else if(i == 2) dp[i] = dp[i - 2] + dp[i - 1];
                else dp[i] = dp[i - 3] + dp[i - 2] + dp[i - 1];
        }
        while(cin >> n && n > 0){
                long long day, year;
                if(dp[n] % 10 > 0) day = dp[n] / 10 + 1;
                else day = dp[n] / 10;
                if(day % 365 > 0) year = day / 365 + 1;
                else year = day / 365;
                cout << year << endl;
        }
        return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

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

int n;
int dp[32];

int main() {
  dp[0] = dp[1] = 1;
  for (int i = 2; i < 31; ++i) {
    for (int j = 1; j <= 3; ++j) {
      if (i - j >= 0) {
        dp[i] += dp[i - j];
      }
    }
  }
  while (cin >> n, n) {
    int nums = dp[n];
    int days = nums / 3650;
    if (nums % 3650) days++;
    cout << days << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  long long fibo[31]={0,1,2,4};
  for(int i=4;i<=30;i++){
    fibo[i] = fibo[i-2]+fibo[i-1]+fibo[i-3];
  }
  int n;
  while(cin >> n,n){
    cout << (fibo[n]%3650?fibo[n]/3650+1:fibo[n]/3650) << endl;
  }
}

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

int main(){
  long long dp[35] = {0LL};

  dp[0] = 1;

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

  int n;

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

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

int dp(int n){
    int A[31];
    for(int i=0; i<31; i++){
    if(i==0)    A[0] = 1;
    else if(i==1) A[1]= 1;
    else if(i==2) A[2]= 2;
    else A[i]=A[i-1]+A[i-2]+A[i-3];
    }
    return A[n];
}

int main(void){
    int n, p;
    while(cin >> n){
        if(n==0)    break;
        p = dp(n);
        if(p%10!=0){
            p = p/10+1;
            if(p>365)   p = p/365+1;
            else        p = 1;
        }
        else{
            p = p/10;
            if(p>365)   p = p/365+1;
            else        p = 1;
        }
        cout << p << endl;
    }
    return 0;
}

C++: #include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(itr,data) for(__typeof((data).begin()) itr=(data).begin();itr!=(data).end();++itr)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;

int solve(int n) {
    long long dp[34];
    rep(i,30) dp[i]=0;
    dp[0]=1;

    rep(i,n) {
        dp[i+1] += dp[i];
        dp[i+2] += dp[i];
        dp[i+3] += dp[i];
    }

    return dp[n]/10/365 + 1;

}

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

C++: #include<iostream>

using namespace std;

typedef long long ll;
const int MAX = 35;
ll ans,dp[MAX];
int in;

void make(){
  dp[0] = 1;

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

}

int main(){
  make();
  while(cin >> in && in) cout << dp[in]/3650+1<< endl;
  return 0;
}