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>
using namespace std;


void solve(vector<int>& a) {
    a[0] = 1;
    for(int i = 1; i <= 30; i++) {
        if(i == 1) {
            a[i] = a[i - 1];
        } if(i == 2) {
            a[i] = a[i - 1] + a[i - 2];
        } else {
            a[i] = a[i - 1] + a[i - 2] + a[i - 3];
        }
    }
    for(int i = 1; i <= 30; i++) {
        a[i] = (a[i] + (3650 - 1)) / 3650;
    }
}

int main() {
    vector<int> a(31);
    solve(a);
    vector<int> inpArray;
    int inp;
    do {
        cin >> inp;
        inpArray.push_back(inp);
    } while(inp != 0);

    for(int i = 0; i < (int)inpArray.size() - 1; i++)
        cout << a[inpArray[i]] << endl;

    return 0;
}

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

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

long long tri(int n)
{
	if(n <= 2)
	{
		return 1;
	}
	else if(n == 3)
	{
		return 2;
	}
	else
	{
		auto table = vector<int>(n+1,0);
		table[0] = 1;
		table[1] = 1;
		table[2] = 2;
		for(int i = 3;i <= n;i++)
		{
			table[i] = table[i-1] + table[i-2] + table[i-3];
		}
		return table[n];
	}
}

int main()
{
	int n;
	cin >> n;
	while(n)
	{
		int s = tri(n);
		int day = (s+9)/10;
		int year = (day+364)/365;
		cout << year << endl;
		cin >> n;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>

int compare_int(const void* a, const void* b) { return *(int*) a - *(int*) b; }

//int n, dp[31];
//
//int func(int p) {
//	if (p == n) {
//		return 1;
//	}
//	int cnt = 0;
//	for (int i = p + 1; n >= i && 3 + p >= i; i++) {
//		if (dp[i] == -1) dp[i] = func(i);
//		cnt += dp[i];
//	}
//	return cnt;
//}
//
//int main() {
//	while (scanf("%d", &n) != EOF) {
//		if (n == 0) return 0;
//		memset(dp, -1, sizeof(dp));
//		printf("%d\n", ((func(0)+9) / 10 + 364) / 365);
//	}
//}

int main() {
	int n, b[2], dp[33] = {};
	scanf("%d", &n);
	dp[n] = 1; dp[n - 1] = 1;
	for (int i = n-2; 0 <= i; i--) {
		dp[i] = dp[i + 1] + dp[i + 2] + dp[i+3];
	}
	printf("%d\n", ((dp[0]+9)/10+364)/365);
	return 0;
}

/*

dp[i] = {dp[i+1]+dp[i+2]+dp[i+3] ????????????

*/

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

using namespace std;
using ll = long long;

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

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int dp[32];
int main() {
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;
    rep(i, 32) {
        if (i - 3 >= 0) {
            dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
        }
    }
    int n;
    while (cin >> n, n) {
        int ans = ceil(dp[n] / 3650);
        cout << ans + 1 << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
	
	long long int ans[40];
	
	for(int i = 0; i < 40; i++){
		ans[i] = 0;
	}
	
	ans[0] = 1;
	
	for(int i = 0; i < 31; i++){
		ans[i + 3] += ans[i];
		ans[i + 2] += ans[i];
		ans[i + 1] += ans[i];
	}
	
	while(true){
		
		int n;
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		cout << (ans[n] + 3649) / 3650 << endl;
		
	}
	
	return 0;
}

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

int main(){
int N;
int a=0;
while(true){
cin >> N;
if(N==0){
break;
}
vector<int> A(N+1);
A.at(0)=1;
A.at(1)=1;
if(N>1){
A.at(2)=2;
}
for(int i=3;i<N+1;i++){
A.at(i)=A.at(i-1)+A.at(i-2)+A.at(i-3);
}
cout << (A.at(N)-1)/3650+1 << endl;
}  
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long 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 pair<long, long> PLL;
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 SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e9;

struct edge{int to,cost;};
typedef pair<int,int> P;//firstは最短距離,secondは頂点番号


int main(){
	int n;
	long res[31];
	res[1]=1;
	res[2]=2;
	res[3]=4;
	FOR(i,4,31)res[i]=res[i-1]+res[i-2]+res[i-3];
	while(cin>>n){
		if(n==0)break;
		long ans=res[n]/10+(res[n]%10!=0);
		cout<<ans/365+(ans%365!=0)<<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>

using namespace std;

typedef long long ll;

int main() {
	int n;
	while ( cin >> n, n ) {
		int dp[50] = {0}; dp[0] = 1;
		for (int i = 0; i < n; ++i) {
			dp[i+1] += dp[i];
			dp[i+2] += dp[i];
			dp[i+3] += dp[i];
		}
		int ans = dp[n] / 3650 + (dp[n] % 3650 ? 1 : 0);
		cout << ans << endl;
	}
}

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

int num(int n);

int main(){
  int n;
  cin>>n;
  cout << num(n)/3650 <<endl;
}

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