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 <cstdio>
typedef long long ll;
int main() {
	int n;
	ll dp[30];
	dp[0]=1; dp[1]=2; dp[2]=4;
	for (int i=3; i<30; i++) dp[i]=dp[i-3]+dp[i-2]+dp[i-1];
	while (scanf("%d",&n)) {
		if (n==0) break;
		ll day,year;
		if (dp[n-1]%10!=0) day=dp[n-1]/10+1;
		else day=dp[n-1]/10;
		if (day%365!=0) year=day/365+1;
		else year=day/365;
		printf("%lld\n",year);
	}
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int n;
LL memo[31];

LL solve(int cnt){
	if(memo[cnt] != -1) return memo[cnt];
	if(cnt >= n) return cnt > n? 0 : memo[cnt] = cnt == n;
	LL res1 = memo[cnt] = solve(cnt + 1);
	LL res2 = memo[cnt] = solve(cnt + 2);
	LL res3 = memo[cnt] = solve(cnt + 3);
	return memo[cnt] = res1 + res2 + res3;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	while(1){
		rep(i,31)
			memo[i] = -1;
		cin >> n;
		if(n == 0) break;
		LL ans = solve(0);
		ans = ans / 10 + 1;
		ans = ans  / 365 + 1;
		cout << ans << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

//AOJ 0168(?????¢????????°)

int memo[31];

int dfs(int k) {
	if (k<= 1) return 1;
	if (k == 2) return 2;
	if (memo[k] == 0) {
		memo[k] = dfs(k - 1) + dfs(k - 2) + dfs(k - 3);
	}
	return memo[k];
}

signed main(){
	int n;
	while (cin>>n && n) {
		cout << (dfs(n) + 3649) / 3650 << endl;
	}
}

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

const int N_MAX=31;
int dp[N_MAX];

int rec(int n){
    int res;
    if(n<0)return 0;
    if(n==0)return 1;
    if(dp[n]>=0){
        return dp[n];
    }else{
        res=rec(n-1)+rec(n-2)+rec(n-3);
    }
    return dp[n]=res;
}

int main(){
    int n;
    while(cin>>n){
        memset(dp,-1,sizeof(dp));
        if(n==0)break;
        cout<<ceil(rec(n)/3650.0)<<endl;
    }
}

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

int main(void){
  int n;
  int dp[31];
  dp[0] = 1;
  dp[1] = 2;
  dp[2] = 4;
  for(int i = 3 ; i < 31 ;  i ++){
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
  }
  while(cin>>n,n){
    cout<<1+dp[n-1]/3650<<endl;
  }
}

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

int solve(int n);
int dp[100];

int main(){
	int n;
	while(cin >> n , n){
		memset(dp,0,n+2);
		int ans = solve(n);
		cout << ans/365/10+1 << endl;
	}
}

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

C++: #include<iostream>

using namespace std;

int dp[35];

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

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

using namespace std;

typedef long long ll;

ll solve(int n) {
    vector<ll> step(n);
    step[0] = 1;
    if( n > 1 ) step[1] = 2;
    if( n > 2 )  step[2] = 4;
    for(int i=3; i < n; ++i){
        step[i] = step[i-3] + step[i-2] + step[i-1];
    }
    return step[n-1];
}

ll getdays(ll ptns){
    if(ptns % 10 == 0) return ptns / 10;
    else return ptns / 10 + 1;
}

ll getyears(ll days){
    if(days % 365 == 0) return days / 365;
    else return days / 365 + 1;
}

int main(){
    int n;
    while(true) {
        cin >> n;
        if(n == 0) break;
        cout << getyears(getdays(solve(n))) << endl;
    }
}

C++: #include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	unsigned long long dp[100];
	dp[0] = 0;
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;
	rep(i,4,40){
		dp[i] = dp[i-1] + dp[i-2] + dp[i-3];	
		//cout << i << ":"  << dp[i] << endl;
	}
	
	rep(i,0,40){
		if(dp[i] % 10 )
			dp[i] = dp[i] / 10 + 1;
		else
			dp[i] = dp[i] / 10;
	}
	
	rep(i,0,40){
		//cout << i << ":" << dp[i] << endl;
	}

	int n;
	while( cin >> n ){
		if( dp[n] % 365 )
			cout << dp[n] / 365 + 1 << endl;
		else
			cout << dp[n] / 365 << endl;
	}
}

C++: #include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  vector<ll> dp(40,1);
  for (int i=1;i<=30;i++){
    dp[i] = dp[i-1];
    if (i>1) dp[i] += dp[i-2];
    if (i>2) dp[i] += dp[i-3];
  }
  rep(i,30){
    int n; cin >> n;
    if (n==0) return 0;
    ll day = (dp[n]+9)/10;
    ll year = (day+364)/365;
    cout << year << endl;
  }
 

  // cout << fixed << setprecision(10);
  
  return 0;
}