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 <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(ll a,ll b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int year(ll n) {
	return mod(n, 3650);
}

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

  int n;
	ll memo[50];
	memo[0] = 1;
	memo[1] = 1;
	memo[2] = 2;
	for(int i = 3; i <= 30; i++) {
		memo[i] = memo[i - 1] + memo[i - 2] + memo[i - 3];
	}
	while(1) {
		cin >> n;
		if(!n) break;
		cout << year(memo[n]) << endl;
	}
  return 0;
}

C++: #include<cstdio>
int i,j,n[99];int main(){n[1]=1;n[2]=2;n[3]=4;for(i=4;i-31;i++)n[i]=n[i-1]+n[i-2]+n[i-3];for(;scanf("%d",&i)&&i;printf("%d\n",n[i]/3650+(n[i]%3650?1:0)));}

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



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


  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    long long stair[31];
    stair[0]=1;stair[1]=1;stair[2]=2;stair[3]=4;
    for(int i=4;i<31;i++)
    {
        stair[i]=stair[i-1]+stair[i-2]+stair[i-3];
    }
    int n;
    int ans=0;
    while(true)
    {
        scanf("%d",&n);
        if(n==0)
        break;
        ans=(stair[n]+3649)/3650;
        cout<<ans<<endl;
    }
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin>>n&&n){
    int ans = 0;
    vary(int,dp,n+3,0);
    dp[1]=1,dp[2]=2,dp[3]=4;
    REP(i,1,n+1){
      if(i > 3){
        REP(j,1,4){
          dp[i] += dp[i-j];
        }
      }
      ans += dp[i]/3650;
    }
    cout << 1+ dp[n] / 3650<<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;
		for (int i = 0; i <= n; ++i)
			dp[i] = 0;

		for (int i = 1; i <= 3; ++i){
			for (int j = 1; j <= n; ++j){
				if (j >= i){
					dp[j] = std::max(dp[j], dp[j - i] + 1);
				}
			}
		}
		printf("%d", dp[n]);
	}
	return 0;
}

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

int  N;

int main() {
	int A[30];
	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 > 0 && N <= 30)
		cout << (A[N] + 364) / 365 << endl;

	}

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

using namespace std;

int kannondo(int n){
  vector<int> a;
  int answer=0;
  a.resize(n+3);
  a[0]=0;
  a[1]=0;
  a[2]=1;
  for (int i=3;i<n+3;i++){
    a[i]=a[i-1]+a[i-2]+a[i-3];
  }
  answer=a[n+2]/3650+1;
  return answer;
}


int main(){
  while(true){
    int a;
    cin>>a;
    if(a==0) break;
    int result;
    result=kannondo(a);
    cout<<result<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repn(i,n,m) for(int i=n;i<m;i++)
#define repn1(i,n,m) for(int i=n;i<=m;i++)
using namespace std;

int main(){

	
	int n;

	while(cin >> n, n){
????????????int dp[100] = {0};
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;

	repn(i, 4, 30) dp[i] = dp[i-1] + dp[i-2] + dp[i-3];

	

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

	return 0;
}

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

int dp[31];

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

  int n;
  while(cin >> n, n){
    cout << ((dp[n]+9)/10+364)/365 << endl;
  }
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) {
      break;
    }
    vector<int> dp(n + 3);
    dp.at(n) = 1;
    for (int i = n - 1; i >= 0; i--) {
      dp.at(i) = dp.at(i + 1) + dp.at(i + 2) + dp.at(i + 3);
    }
    int total = dp.at(0);
    int day = 0;
    while (total > 0) {
      total -= 10;
      day++;
    }
    int year = (day + 365 - 1) / 365;
    cout << year << endl;
  }

  return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1000100;//1LL << 60;

int main() {
  int n;
  vector<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];
  }
  
  while(cin>>n){
    if(n>0){cout<<(dp[n]+3649)/3650<<endl;}
  }
  return 0;}

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 = 3; 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;
	}
}