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
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	LL dp[40] = {0};
	dp[0] = 1;
	for (int i = 0; i < 31; 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] % 3650 ? dp[n] / 3650 + 1 : dp[n] / 3650) << endl;
	}
}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

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

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

int main() {
  int n;
  long long int dp[31];
  
  while(cin>>n, n) {
    fill(dp, dp+31, 0);
    dp[0]=dp[1]=1; dp[2]=2; dp[3]=4;
    if(n==1) { cout << 1 << endl; continue; }
    else if(n==2) { cout << 2 << endl; continue; }
    else {
      for(int i=4; i<30; i++) {
	dp[i]=dp[i-3]+dp[i-2]+dp[i-1];
      }
    }

    cout << dp[n]/3650+1 << endl;
  }

  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <cstring>
using namespace std;

int n;
int way[30];

int main(void){

	cin >> n;
	while(n != 0){

		for(int i = 0; i < n; i++){
			way[i] = 0;
		}
		
		way[0] = 1;
		way[1] = 2;
		way[2] = 4;

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

		double ans = way[n - 1] / 3650.0;

		cout << ceil(ans) << endl;

		cin >> n;
	}

    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  cout << num((int)s) <<endl;
  return 0;
}

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

C++: #include<iostream>

using namespace std;

int solve(int n){
	int kai[31]={};
	kai[0]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=3;j++){
			if(i-j>=0){
				kai[i]+=kai[i-j];
			}
		}
	}
	int sum=0;
	for(int i=1;i<=n;i++){
		sum+=kai[i];
	}
	return ((kai[n]+9)/10+364)/365;
}
int main(){

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

		cout<<solve(n)<<endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vll;

const int N = 31;

ll calc(int n,vll& memo){
    if(memo[n] != -1) return memo[n];
    ll ret = 0;
    for(int i=1;i<=3;i++){
        ret += calc(n-i,memo);
    }
    return memo[n] = ret;
}

int main(){
    vll memo(N,-1);
    memo[1] = 1;
    memo[2] = 2;
    memo[3] = 4;
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        cout << calc(n,memo) / 3650 + 1 << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

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

        vector<ll> dp(n+1);
        dp[0]=dp[1]=1;
        dp[2]=2;
        for (int i = 3; i < dp.size(); i++)
        {
            dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
        }
        int d,a,b;
        d=ceil(dp[n]/10);
        a=d/365;
        b=d%365;
        if(a>0)
        {
            if(b>0) a++;
            cout<<a<<endl;
        }
        else cout<<1<<endl;
    }
    

    return 0;
}

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

int f(int n){
    if(n == 1)return 1;
    if(n == 2)return 2;
    if(n == 3)return 4;
    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;
    }
}