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<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 101

int dp[30];

int main(){

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

    while(cin >> n,n){
        cout << (dp[n]-1)/3650+1 << endl;
    }

    return 0;
}

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

int main()
{
	int n;
	int dp[30];
	int year;
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	while(cin >> n && n != 0){
		
		for(int i = 0; i < n; i++)
		{
			dp[i+3] = dp[i+2] + dp[i+1] + dp[i]; 
		}
		year = dp[n]/3650 + 1;
		cout << year << endl;
	}
	return 0;
}

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

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main(){
  int n;
  int a[30];

  while(cin >> n && n > 0){
    a[0] = 1;
    a[1] = 2;
    a[2] = 4;
    REP(i, 3, n){
      a[i] = a[i-1] + a[i-2] + a[i-3];
    }

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

}

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>

using namespace std;
vector <int> memo;

int f(int n){
	memo[0]=1;
	memo[1]=2;
	memo[2]=4;
	
	for(int i = 3;i < 30 ; i++){
		memo[i] = memo[i-1]+memo[i-2]+memo[i-3];
	}
	if(n < 0){
		return 0;
	}
	if(n == 0){
		return 1;
	}
	return memo[n]/10/365+1;
}
int main(){
	int n;
	memo.resize(31,-1);
	while(cin >> n,n){
		n -= 1;
		int num = f(n);
		cout << num << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <cstdio>
using namespace std;
int x, c=0;
void dfs(int pos) {
	if (pos == 1) {
		c++;
		return;
	}else if (pos == 2) {
		c = c + 2;
		return;
	}
	else if (pos == 3) {
		c = c + 4;
		return;
	}
	else {
		dfs(pos - 1);
		dfs(pos - 2);
		dfs(pos - 3);
	}


}

int main() {
	while (1) {
	int	days = 0, years = 0;
	c = 0;
	cin >> x;
	if (x == 0) {
		break;
	}
	dfs(x);
	days = c / 10;
	if (c % 10 != 0) {
		days++;
	}
	years = days / 365;
	if (days % 365 != 0) {
		years++;
	}
	cout << years << endl;
	}
	

}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <cstring>
#include <string>
#include <sstream>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int Y = 365;

int main(void){
    int dp[30];
    for(int n, cnt; cin >> n, n; cnt = dp[n - 1] / 10 + (!!dp[n - 1] % 10), cout <<  cnt / Y + (!!cnt % Y) << endl)
        rep(i, n) dp[i] = (i < 3) ? 1 << i:dp[i - 3] + dp[i - 2] + dp[i - 1];

    return 0;
}

C++: #include <iostream>
using namespace std;
 
int num(int n);
 
int main(){
  int n;
  cin>>n;
  cout << num(n)/3650 + 1<<endl;
}
 
int num(int n){
    switch (n)
    {
        case -1: return 0;
        case 0:  return 0;
        case 1:  return 1;
    }
  return num(n-1)+num(n-2)+num(n-3);
}

C++: #include<iostream>
using namespace std;
long long n[50], p;
int main() {
	n[0] = 1; n[1] = 1; n[2] = 2;
	for (int i = 0; i < 40; i++) {
		n[i] = n[i - 1] + n[i - 2] + n[i - 3];
	}
	while (true) {
		cin >> p;
		if (!p) { break; }
		cout << (n[p] + 3649) / 3650 << endl;
	}
}

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

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

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

int dp[31];

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

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

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)

int main(){
    int dp[50];
    rep(i,50)dp[i]=0;
    dp[0]=1;
    rep(i,35){
        for(int j=1;j<=3;j++){
            dp[i+j]+=dp[i];
        }
    }
    
    
    int n;
    while(cin>>n&&n){
        cout<<ceil(dp[n]/3650.0)<<endl;
    }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
#include <fstream>
#include <valarray>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#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)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const long double pi=acos(-1.0);
int dx[]={0,1,0,-1,1,1,-1,-1,0},dy[]={1,0,-1,0,1,-1,1,-1,0};

ll dp[31];

main(){
  dp[0]=1;

  for(int i=1;i<=30;++i)
    for(int j=max(0,i-3);j<i;++j)
      dp[i]+=dp[j];
  int n;
  while(cin>>n,n)cout<<(dp[n]+3649)/3650<<endl;
}