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<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int a[31]={1,1,2};
  int n;
  loop(i,3,31)a[i]=a[i-1]+a[i-2]+a[i-3];
  while(cin>>n,n)cout<<(a[n]-1)/365/10+1<<endl;
}

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

int dp[40];

int main(void)
{
    memset(dp, 0, sizeof(dp));

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

    while(true) {
        int n;
        scanf("%d", &n);
        if(!n) break;

        printf("%d\n", (int)ceil((double)dp[n]/365/10));

    }

    return 0;
}

C++: #include<iostream>

using namespace std;

int ProgressNumberOfYears(int step_num, int step_kind)
{

  if(step_num == 0)
    return 1;
  else if(step_num < 0)
    return 0;

  int count = 0;

  for(int i = 1; i < 4; ++i) count = count + ProgressNumberOfYears(step_num - i,i);

  return count;

}

int main()
{

  int step_num;

  while(cin >> step_num && step_num != 0) cout << ProgressNumberOfYears(step_num,0)/10/365 + 1<< endl;

  return 0;

}

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

int ans;

int rec(int n, int now) {
  static int ans;
  if(now == 0) ans = 0;
  for(int i = 1; i <= 3; i++) {
    int next = now+i;
    if(next >= n) {
      ans++;
      break;
    }
    rec(n, next);
  }
  if(now == 0) return ans;
}

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

    int ans;
    ans = rec(n, 0);
    cout << ( (ans+10)/10 -1 )/ 365 + 1 << endl;
  }
  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include<cstdio>
#include<algorithm>

#define N_MAX 30

int main(){
	while (1){
		int n, dp[N_MAX + 1];
		scanf("%d", &n);
		if (n == 0)
			break;
		std::fill(dp, dp + n + 1, 0);
		dp[0] = 1;
		dp[1] = 1;
		dp[2] = 2;
		for (int i = 3; i <= n; ++i){
			for (int j = 1; j <= 3; ++j){
				if (j <= i){
					dp[i] += dp[i - j];
				}
			}
		}
		int day = (dp[n] % 3650 == 0) ? dp[n] / 3650 : dp[n] / 3650 + 1;
		printf("%d", day);
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int a[31];

int main (void){
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];
int n;
while(cin >> n,n|0){
    int ans=a[n]/3650;
    if(a[n]%3650)
         ans++;
    cout << ans << endl;
}
return 0;
}

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

long long calc(int x){
    if(x < 0) return 0;
    if(x == 0) return 1;
    return calc(x - 1) + calc(x - 2) + calc(x - 3);
}

int main(){
    long long n;
    while(cin >> n){
        cout << (calc(n) + 3649) / 3650 << endl;
    }
}

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

long long calc(int x){
    if(x < 0) return 0;
    if(x == 0) return 1;
    return calc(x - 1) + calc(x - 2) + calc(x - 3);
}

int main(){
    long long n;
    while(cin >> n){
        cout << (calc(n) + 3640) / 3650  << endl;
    }
}

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

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    vector<long long> dp(n + 1);
    for (int i = 0; i <= n; i++) {
      if (i == 0) dp[i] = 1;
      else if (i == 1) dp[i] = 1;
      else if (i == 2) dp[i] = 2;
      else dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
    }
    cout << ((dp[n] + 9) / 10 + 364) / 365 << endl;
  }
}

C++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

long long dp[30+1];

long long get_dp(int n);

int main(void) {
    for (int i = 0; i <= 30; i++) dp[i] = -1;
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;
        long long ans, tmp;
        tmp = get_dp(n);
        ans = tmp / 10;
        if (ans * 10 < tmp) ans++;
        tmp = ans / 365;
        if (tmp * 365 < ans) tmp++;
        cout << tmp << endl;
    }

    return 0;
}

long long get_dp(int n) {
    if (dp[n] != -1) return dp[n];
    else if (n == 0 || n == 1) return dp[n] = 1;
    else if (n == 2) return dp[n] = 2;
    else return dp[n] = get_dp(n-1) + get_dp(n-2) + get_dp(n-3);
}

C++: #include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int main(){
	int dp[31],n;
	dp[1]=1;dp[2]=2;dp[3]=4;
	r(i,4,31)dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
	while(cin>>n,n){
		n=dp[n]/3650;
		if(!n)n=1;
		else n++;
		cout<<n<<endl;
	}
}

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

int main()
{
  int dp[40];
  fill_n(dp, 40, 0);

  dp[0] = 1;

  for (int i = 1; i < 40; ++i) {
    for (int j = 1; j <= 3; ++j) {
      if (i-j>=0) dp[i] += dp[i-j];
    }
  }

  int n;
  while (cin >> n) {
    int ans = dp[n] / 3650;
    if (dp[n] % 365 != 0) ans++;
    cout << ans << endl;
  }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
  int n, stair[31];
  while (cin >> n, n) {
    memset(stair, 0, sizeof(int) * 31);
    stair[0] = 1;

    for (int i = 1; i <= n; i++) {
      stair[i] += stair[i-1];
      if (i - 2 >= 0)
        stair[i] += stair[i-2];
      if (i - 3 >= 0)
        stair[i] += stair[i-3];
    }
    cout << stair[n] / 3650 + 1 << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <unordered_set>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 1000000009;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()

int main()
{
	int n;
	vector<int> dp(35);
	dp[0] = 1;
	REP(i, 30)REP(j, 3)dp[i + 1 + j] += dp[i];
	while (cin >> n)
	{
		cout << (dp[n] / 365 / 10 + !!(dp[n] / 10 % 365)) << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int dan[45]={0},nen[45]={0};
    int n;
    dan[1]=1;
    nen[1]=1;
    dan[2]=2;
    dan[3]=4;
    for(int i=4;i<=35;i++)
    {
        dan[i]=dan[i-1]+dan[i-2]+dan[i-3];
    }
    for(int i=2;i<=35;i++)
    {
        nen[i]=dan[i]/10/365;
        if(dan[i] / 10 % 365 != 0)
        {
            nen[i]++;
        }
    }
    while(cin>>n)
    {
        if(n==0)break;
        cout<<nen[n]<<endl;
    }
    return 0;
}

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

int n,dp[31];

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

int main(){
    while(cin >> n,n){
        fill(dp,dp+31,0);
        dp[0] = 1; dp[1] = 1; dp[2] = 2;
        cout << rec(n)/3650 + 1<< endl;
    }
}