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 <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;

long long int dp[31];

int main(){
	int n;
	while(cin>>n&&n){
		for(int i=0; i<=n; ++i){
			dp[i]=0;
		}
		dp[0]=1;
		for(int i=1; i<=n; ++i){
			if(i>=1){
				dp[i]+=dp[i-1];
			}
			if(i>=2){
				dp[i]+=dp[i-2];
			}
			if(i>=3){
				dp[i]+=dp[i-3];
			}
		}
		int ans=(((dp[n]+9)/10)+364)/365;
		cout << ans << "\n";
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
 
int num(int n);
 
int main(){
  int n;
  cin>>n;
  cout << (num(n)+3649)/3650<<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<stdio.h>
long long int dp[30];
int main(){
	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];
	int a;
	while(scanf("%d",&a),a)printf("%d\n",((dp[a-1]+9)/10+364)/365);
}

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

int main() {
    int a[100]={0};
    a[0]=1;
    a[1]=1;
    a[2]=2;
    int n;
    while(cin <<n){
    int x;
    x=0;
    for(int i=3;i<n;i++){
    	a[i]=a[i-3]+a[i-2]+a[i-1];
    }
    x=a[n]%3650;
    x=x+1;
    cout >> x;
    
    }
	return 0;
}

C++: /* competitive programming circle traP */
/* template */
#include <stdio.h>

int main(){
  // initialize
  int dp[31];
  dp[0] = 1;
  dp[1] = 1;
  dp[2] = 2;
  for(int n=3;n<=30;n++){
    dp[n] = dp[n-1];
    dp[n] += dp[n-2];
    dp[n] += dp[n-3];
  }
  for(int n=0;n<=30;n++){
    dp[n] = (dp[n]+3650-1)/3650;
  }
  // in/out
  while(true){
    int n;
    scanf("%d",&n);
    if(n==0)break;
    printf("%d\n",dp[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[30];

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]) dp[i] = func(i);
		cnt += dp[i];
	}
	return cnt;
}

int main() {
	scanf("%d", &n);
	printf("%d\n", (func(0)/10+364)/365);
}

C++: #include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
// bool operator<(const pair<int, int> &a, const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first < b.first;
// };

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

/*bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return a.second < b.second;
    }
    return a.first < b.first;
}*/
/*cin.tie(0);
    ios::sync_with_stdio(false);
*/
ll fib[31];
int main()
{
    fib[0] = 0;
    fib[1] = 1;
    fib[2] = 2;
    fib[3] = 4;
    for (int i = 4; i <= 30; ++i)
    {
        fib[i] = fib[i - 1] + fib[i - 2] + fib[i - 3];
    }
    int n;
    while (cin >> n, n)
    {
        cout << ((fib[n] % 3650) ? fib[n] / 3650 + 1 : fib[n] / 3650) << endl;
    }
    return 0;
}

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

int a[10000];
int s;
int main(){
  while(cin >> s && s != 0){
    a[0] = 1;
    a[1] = 1;
    a[2] = 2;
    for(int i = 3; i < s + 1; ++i){
      a[i] = a[i-1] + a[i-2] + a[i-3];
    }
    cout << ((a[s]/10)/365) + 1 <<endl;
  }
}

C++: #include <iostream>

using namespace std;

int main()
{
    int n;
    while (cin >> n && n)
    {
        int a = 1;
        int b = 2;
        int c = 4;
        int sum;
        int answer;
        for (int i = 4; i <= n; i++)
        {
            sum = a + b + c;
            a = b;
            b = c;
            c = sum;
        }
        if (n <= 3)
        {
            answer = 1;
        }
        else
        {
            answer = (sum / +10) / 365;
            if (sum % 3650 != 0)
            {
                answer += 1;
            }
        }

        cout << answer << endl;
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
int dp[31];
int solve(int d){
    if(dp[d] != -1)
        return dp[d];
    else
        return dp[d] = solve(d-1) + solve(d-2) + solve(d-3);
}

int main(){
    int n;
    for(int i = 0; i < 31; i++)
        dp[i] = -1;
    dp[1] = 1;
    dp[2] = 2;
    dp[3] = 4;
    while(cin >> n,n){
        if(n == 1 || n == 2 || n == 3)
            cout << 1 << endl;
        else
            cout << solve(n) / 10 / 365 + 1 << endl;
    }
}

C++: #include <iostream>

using namespace std;
/** Problem0168 : Kannondou **/
int main()
{
	int n, k[31];
	k[0] = 1; k[1] = 1; k[2] = 2; k[3] = 4;
	for (int i=4; i<31; i++) {
		k[i] = k[i-1] + k[i-2] + k[i-3];
	}
	
	while (cin >> n, n!=0) {
		cout << k[n]/10/365+1 << endl;
	}
	return 0;
}

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

signed main() {
	vector<int> a(128);
	int N;

	a[0] = 1;
	for (int i = 1; i <= 32; ++i) {
		a[i] = a[i-1];
		if (i >= 2) a[i] += a[i-2];
		if (i >= 3) a[i] += a[i-3];
	}
	
	while (cin >> N && N) {
		cout << ceil((double)a[N] / 3650) << endl;
	}
}

C++: #include<iostream>

long long int a[31];

int main(){
	int n;
	a[0] = 1, a[1] = 1, a[2] = 2;
	for (int i = 3; i <= 30; ++i){
		a[i] = a[i - 1] + a[i - 2] + a[i - 3];
	}
	while (std::cin >> n ,n){
		
		std::cout << (a[n]/3650)+1 << std::endl;
	}
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main(){
    int kazu[35];
    kazu[1]=1;
    kazu[2]=2;
    kazu[3]=4;
    for(int a=4;a<=30;a++)
kazu[a]=kazu[a-1]+kazu[a-2]+kazu[a-3];
     
    while(1)
  {
        int n;
        cin>>n;
        if(n==0)break;
        cout<<(kazu[n]/10+1)/365+1<<endl;
    }
     
    return 0;
}

C++: #include<iostream>
#include<sstream>
#include<iomanip>
#include<stdlib.h>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<utility>
#include<algorithm>
using namespace std;
#define loop(i,l,r) for(int (i)=(int)(l);(i)<(int)(r);(i)++)
#define rloop(i,l,r) for(int (i)=(int)(l);(i)>(int)(r);(i)--)
#define rep(i,n) loop(i,0,n)
#define rrep(i,n) rloop(i,n-1,-1)
#define INF 0x3f3f3f3f
#define mod 1000000007
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

int main(){
	int dp[31],d;
	fill(dp,dp+31,0);
	dp[0]=1;
	rep(i,30)rep(j,3)if(i-j>=0)dp[i+1]=dp[i+1]+dp[i-j];
	while(1){
		cin>>d;
		if(d==0)break;
		cout<<dp[d]/3650+1<<endl;
	}
}