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

int dp[31] = {1,1,2};
int ans[31];
int n;

int main(){
  
  for(int i = 3 ; i < 31 ; i++){
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
  }
  for(int i = 0; i < 31 ; i++){
    ans[i] = dp[i] / 10;
    if(dp[i] % 10 != 0) ans[i]++;
    ans[i] = ans[i] / 365 ;
    if(ans[i] % 365 != 0) ans[i]++;
    if(ans[i] == 0) ans[i]++;
  }
  /*
  for(int i = 0; i < 31 ; i++){
    cout << ans[i] << " ";
  }
  cout << endl;
  for(int i = 0; i < 31 ; i++){
    cout << dp[i] << " ";
  }
  */
  while(cin >> n, n != 0){

    cout << ans[n] << endl; 
  }
  
  return 0;
}

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

const int kMaxJumpStep = 3;

int dp(const int N){
	std::vector<int> step(N+1);
	step[0] = 1;

	for (int i = 0; i <= N; i++){
		for (int j = i + 1; j <= i + kMaxJumpStep; j++){
			if (j > N) break;
			step[j] += step[i];
		}
	}

	return step[N];
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	while (1){
		int n;
		std::cin >> n;
		if (n == 0) break;
		std::cout << dp(n)/3650 + 1 << std::endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

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

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

    if(dp[n]%365==0){
      cout << dp[n]/3650 << endl;
    }else{
      cout << dp[n]/3650+1 << endl;
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

bool Memo[32] = {1,1,1};
int Trib[32] = {0,1,1};
int trib(int num){
	for(int i = 3;i <= num+1;i++){
		if(Memo[i])continue;
		Trib[i] = Trib[i-1] + Trib[i-2] + Trib[i-3];
		Memo[i] = 1;
	}
	return Trib[num+1];
}

int main(){
	int n;
	int ans; 
	while(cin >> n,n){
		ans = trib(n);
		if(ans  % 3650  == 0){
			ans = ans/3650;
		}else{
			ans = ans/3650+1;
		}
		cout << ans << endl;
	}	
	return 0;
}

C++: #include <iostream>

int dp[31];
int count(int n){
	if(dp[n] < 0){
		dp[n] = count(n-3)+count(n-2)+count(n-1);
	}
	return dp[n];
}
using namespace std;
int main(){
	for(int i = 0; i < 30; ++i){
		dp[i] = -1;
	}
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;
	int n;
	cin >> n;
	while(n){
		cout << ((count(n)+9)/10+364)/365 << endl;
		cin >> n;
	}
}

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

typedef long Int;

Int dp[100];

Int solve(Int n){
  Int rtn = 0;
  if(dp[n] != -1){
    rtn = dp[n];
  } else {
    if(n < 0){
      rtn = 0;
    } else if(n == 0){
      rtn = 1;
    } else {
      rtn = 0;
      rtn += solve(n-1);
      rtn += solve(n-2);
      rtn += solve(n-3);
    }
    dp[n] = rtn;
  }
  return rtn;
}


int main(void){
  memset(dp,-1,sizeof(dp));
  Int n;
  while(cin >> n , n){
    cout << solve(n)/10/365 + 1 << endl;
  }
  return 0;
}

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] / 10 / 365 + (stair[n] / 10 % 365 ? 1 : 0) << endl;
  }
  return 0;
}

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

int main() {
	cin.tie(false);
	ios::sync_with_stdio(false);

	for(int n; cin >> n, n;) {
		vector<int> dp(n + 1, 0);
		dp[0] = 1;
		for(int i = 0; i < dp.size(); ++i)
			for(int j = i + 1; j < dp.size() && j < i + 4; ++j)
				dp[j] += dp[i];

		int day = dp[n] / 10 + (dp[n] % 10 ? 1 : 0);
		int year = day / 365 + (day % 365 ? 1 : 0);
		cout << year << endl;
	}


	return EXIT_SUCCESS;
}

C++: #include <bits/stdc++.h>

using namespace std;

/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)  //a~(b - 1)?????§
#define print(i) cout << i << endl //?°??????????Python?????????
#define all(i) (i).begin(),(i).end() //??¨??????(sort??¨???)
#define mp make_pair //mp(OO, OO)??¨???:::pint??¨???

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/

int main(void)
{
  int n;
  int dp[35] = {1, 1, 2};

  FOR(i, 3, 31){
    dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
  }

  while (cin >> n){
    cout << dp[n] / 10 / 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] % 10 == 0) ? dp[n] / 10 : dp[n] / 10 + 1;
		int ans = (day % 365 == 0) ? day / 365 : day / 365 + 1;
		printf("%d",ans);
	}
	return 0;
}

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

int main(){
	int data[31];
	data[1]=1,data[2]=2,data[3]=4;
	for(int i=4;i<31;i++)data[i]=data[i-1]+data[i-2]+data[i-3];
	int n;
	while(std::cin>>n,n){
		std::cout<<std::ceil(data[n]/10.0/365.0)<<std::endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
int n;

int cnt(int i){
	if(i == 1)	return 1;
	if(i == 2)	return 2;
	if(i == 3)	return 4;

	return cnt( i-3 ) + cnt( i-2 ) + cnt( i-1 );
}


int main(void){
	std::cin >> n;
	std::cout << std::ceil(cnt(n) / 10.0 / 365.0) << std::endl;
	return 0;
}

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

#define int long long

int dp[50];
int n;

void init() {
  dp[1] = dp[2] = dp[3] = 1;
  for (int i = 1; i <= 30; i++) {
    dp[i+1] += dp[i];
    dp[i+2] += dp[i];
    dp[i+3] += dp[i];
  }
}

signed main() {
  init();
  while (1) {
    cin >> n;
    if (n == 0) break;
    int year = dp[n] / 3650;
    int day = (dp[n] + 3650 - 1) / 3650
    cout << max(1LL, year + (days >= 1)) << endl;
  }

  return 0;
}

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

int main()
{
  int n;
  long long day[32];

  day[0] = 0;
  day[1] = 1;
  day[2] = 1;

  for (int i = 3; i <= 31; i++){
    day[i] = day[i - 3] + day[i - 2] + day[i - 1];
  }

  while (cin >> n, n){
    int year = day[n + 1] / 10 / 365;
    cout << year + 1 << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
const long long INF=1LL << 60;



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> dan(35,0);
    vector<int> dp(35,0);
    int N;
    for(int i=0;i<35;i++){
        int tmp;
        cin>>tmp;
        if(tmp==0){
            N=i;
            break;
        }
        dan[i]=tmp;        
    }
    dp[0]=1;
    for(int i=1;i<31;i++){
        dp[i]+=dp[i-1];
        if(i>1)dp[i]+=dp[i-2];
        if(i>2)dp[i]+=dp[i-3];
    }
    for(int i=0;i<N;i++){
        int tmp=dp[dan[i]]/3650;
        if(dp[dan[i]]%3650!=0) tmp++;
        cout << tmp <<endl;
    }

    return 0;
}