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>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int dp[50];
int main() {
  int n;
	dp[0] = 1;
	for (int i = 1; i <= 30; i++) {
		dp[i] += dp[i - 1];
    //cout << dp[i] << " ";
		if (i >= 2)dp[i] += dp[i - 2];
    //cout << dp[i] << " ";
		if (i >= 3)dp[i] += dp[i - 3];
    //cout << dp[i] << " ";
    //cout << endl;
	}
  while (cin >> n,n) {
  cout << dp[n]/10/365+1 << endl;
  }
  return 0;
}

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

int dan;
long long int memo[40];

int main(){
  memo[1]=1;
  memo[2]=2;
  memo[3]=4;
  for(int i=4;i<31;i++){
    memo[i]=memo[i-1]+memo[i-2]+memo[i-3];
  }
  
  while(1){
    cin>>dan;
    cout<<dan;
    if(dan==0){break;}
    cout<<memo[dan]<<endl;
    }
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_N=30;

typedef long long ll;

int N;

ll dp[MAX_N+1];

int main(){
	dp[1]=1;
	dp[2]=2;
	dp[3]=4;
	FOR(i,4,MAX_N+1){
		dp[i]=dp[i-3]+dp[i-2]+dp[i-1];
	}
	do{
		cin>>N;
		if (N){
			ll day=(dp[N]+9)/10;
			ll y=(day+364)/365;
			cout<<y<<endl;
		}
	}while (N);
	return 0;
}

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

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

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

int main(){
    int n;
    int count[30];
    while(cin >> n, n){
        for(int i = 0;i < n;++i){
            count[i] = i < 3 ? 1 : 0;
        }
        for(int i = 0;i < n;++i){
            for(int j = 1;j < 4;++j){
                if(i + j >= n) break;
                count[i + j] += count[i];
            }
        }
        cout << count[n - 1] / 3650 + 1 << endl;
    }
}

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

int com(int x,int y){
  long long int ans;
  if(y==0)return 1;
  if(y==1)return x;
  ans = x;
  for(int i=1;i<y;i++)ans *= x-i;
  for(int i=0;i<y;i++)ans /= y-i;
  return ans;
}

int main(){
  int n;
  int a,d,y;

  while(1){
    cin >> n;
    if(!n)break;

    a = 0;
    for(int i=0;i<=n/3;i++){
      for(int j=0;j<=(n-3*i)/2;j++){
	a += com(i+j+(n-3*i-2*j),i+j) * com(i+j,i);
      }
    }

    d = a/10;
    if(d*10 != a)d++;
    y = d/365;
    if(y*365 != d)y++;
    cout << y << endl;
  }
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T, typename U>
void print1(T Array, U size) {
  for (int i = 0; i < size; i++) {
    cout << Array[i] << " ";
  }
  cout << endl;
}

template<typename T>
void print(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

// ------------------------------------------------------------------------------------------

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 kind = dp[n] / 10;
    int year = kind / 365;
    int days = kind % 365;
    cout << year + (days >= 1) << endl;
  }

  return 0;
}

C++: #include <algorithm>
#include <iostream>
using namespace std;
int A[32], N;
int main(){
	A[0] = 1;
	for (int i=1; i<=31; i++){
		A[i] = A[i-1];
		if (i>1) A[i] += A[i-2];
		if (i>2) A[i] += A[i-3];
	}
	while (cin >> N && N!=0){
		int year = A[N]/3650+1;
		cout << year << endl;
	}
}

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

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

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

  for (int i = 3; i <= 30; 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<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)

int main(void){
	int n;
	long long a[30]={1,2,4};
	loop(i,3,30)
		a[i] = a[i-1] + a[i-2] + a[i-3];
	while(cin>>n,n)
		cout<<1+a[n-1]/3650<<endl;
		
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<utility>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define all(v) v.begin(),v.end()
using namespace std;

const double eps = 1e-8;
const double INF = 1e12;

typedef pair<long,long> P;
typedef double Real;
typedef complex<Real> Point;
typedef vector<Point> G;

double cross(const Point& a,const Point& b){//calculate ad-bc(vector product)
	return imag(conj(a)*b);
}

struct L:public vector<Point>{//line data
	L(const Point &a,const Point &b){
		push_back(a);
		push_back(b);
	}
};

int n;

long long func(int i){//i??????????§???????n??????????????????????????°???????????¢??°
	long long res;
	if(i==n)return 1;
	else if(i==n-1)res=func(i+1);
	else if(i==n-2)res=func(i+1)+func(i+2);
	else res=func(i+1)+func(i+2)+func(i+3);
	return res;
}

int main(){
	while(cin>>n){
		if(!n)break;
		long long sum=func(0);
		int ans=sum/3650;
		if(sum%365)ans++;
		cout<<ans<<endl;
	}
	return 0;
}

C++: 

#include<iostream>
using namespace std;

int main(){
  int n,c=0;
  while(true){
  cin>>n;
  if(n==0){
    break;
  }
  int dp[n+1];
  for(int i=0;i<n+1;i++){
    if(i==0){
      dp[i]=1;
    }
    if(i==1){
      dp[i]=1;
    }
    if(i==2){
      dp[i]=2;
    }
  }
  
  for(int i=3;i<n+1;i++){
      dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
  }
  if(c==0){
    cout<<endl;
    ++c;
  }
  cout<<dp[n]/3650+1<<endl;
  }
}

C++: #include <iostream>
using namespace std;
#define rep(i,x,to) for(int i=x;i<to;i++)

int main() {
	int n,dp[30]={1,1,2};
	while(1){
		cin >> n;
		if(n==0) break;
		rep(i,3,30){
			dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
		}
		cout << dp[n]/10/365+1 << endl;
	}
	return 0;
}