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;

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    lint d[40];
    d[0] = 1;
    d[1] = 1;
    d[2] = 2;
    REP(p, 3, 40){
        d[p] = d[p-3] + d[p-2] + d[p-1];
    }
    int n;
    while(cin >> n, n){
        lint day = (d[n] - 1) / 10 + 1;
        lint year = (day - 1) / 365 + 1;
        cout << year << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
      int tmp,dp[31];
      cin >> tmp;
      do{
            fill(dp,dp+31,0);
            dp[0] = 1;
            for (int i = 0; i<tmp;i++){
                  for(int j = 1;j < 4;j++)
                        dp[i+j] += dp[i];
            }
            cout << dp[tmp]/3650 + 1<<endl;
            cin >> tmp;
      }while(tmp);
}

C++: #include <algorithm>
#include <iostream>
using namespace std;
int A[128],N;
int main() {
  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 << ((A[N]+9)/10 + 364)/365 << endl;
  }
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,b,c,d,n,dp[31];
	dp[1]=1;
	dp[2]=2;
	dp[3]=4;
	for(int i=4;i<31;i++){
		dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
	}
	while(1){
		cin>>n;
		if(n==0)break;	
		a=dp[n]/10;
		b=dp[n]%10;
		if(b>0)a++;
		c=a/365;
		d=a%365;
		if(d>0)c++;
		cout<<c<<endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 28)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}

typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int n;
int memo[32];
int dfs(int now){
	if(now > n)return false;
	if(now == n)return true;
	if(memo[now] != -1)return memo[now];
	int sum = dfs(now+1) + dfs(now+2) + dfs(now+3);
	return memo[now] = sum;
}

int main(void){
	while(cin >> n, n){
		fill_n(memo, 32, -1);
		cout << dfs(0)/3650+1 << endl;
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

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

int memo[30];

int main(){
	int n,ans;
	
	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(cin>>n){
		if(n==0)break;
		if(memo[n]%365!=0)ans=memo[n]/(365*10)+1;
		else ans=memo[n]/365;
		cout<<ans<<endl;
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int n;
int memo[31], ans[31];
int main(){
  while(cin>>n){
    if(!n)
      return 0;
    memo[0]=1;
    memo[1]=1;
    memo[2]=2;
    for(int i=3;i<=n;i++){
      if(!memo[i]){
	memo[i]=memo[i-1]+memo[i-2]+memo[i-3];
      }
    }
      if(memo[n]%3650)
      ans[n]+=1;
      ans[n]+=memo[n]/3650;
      cout<<ans[n]<<endl;
  }
  return 0;
}

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

#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MAX_N = 35;
//const int MAX_V = 100100;

int data[MAX_N]; 

int main(){
    int data_num=0;
    REP(i,MAX_N){
        cin >> data[i];
        data_num++; 
        if(data[i]==0) break;
    }
    int dp[MAX_N];
    dp[1] = 1;
    dp[2] = 2;
    dp[3] = 4;
    FOR(k,4,31){
        dp[k] = dp[k-1] + dp[k-2] + dp[k-3];
    }
    REP(i,data_num-1){
        cout << ceil(dp[data[i]]/3650.0) << endl;
    }
    
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n;
    int a[15000] = {0};
    while(scanf("%d",&n),n){
    int ans = 0;
    a[0] = 1;
    a[1] = 1;
    a[2] = 2;
    for(int i = 3;i <= n; i++){
        a[i] = a[i-1] + a[i-2] + a[i-3];
    }
    ans = a[n]/3650;
    printf("%d\n",ans+1);
    }
    return 0;
}

C++: #include <iostream>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <sstream>
using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long

int n;

int a[30];

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

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

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

int main(){
  
  for(int i = 3 ; i < 30 ; i++){
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
    ans[i] = dp[i] / 10;
    if(dp[i] % 10 != 0) ans[i]++;
    ans[i] = ans[i] / 365;
    if(dp[i] % 365 != 0) ans[i]++;
  }
  for(int i = 0; i < 30 ; i++){
    if(ans[i] == 0) ans[i] = 1;
  }

  while(cin >> n, n != 0){

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

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

int n;
int A[31];
/*DP????????????????????????*/
int solve(int k){
        if(A[k]>=0) return A[k];
        if(k==0) return A[k]=1;
        if(k==1) return A[k]=solve(k-1);
        if(k==2) return A[k]=solve(k-1)+solve(k-2);
        return A[k]=solve(k-1)+solve(k-2)+solve(k-3);
}

int main(){
        while(1){
                scanf("%d",&n);
                if(n==0) break;
                memset(A,-1,sizeof(A));
                printf("%d\n",solve(n)/10/365+1);
        }
        return 0;
}

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

int A[128], N;

int main() {

	while ( cin >> N && N ) {

		A[0] = 1;
	
		for ( int i = 1; i <= N; i++ ) {
	
			A[i] = A[i-1];
		
			if ( i >= 2 ) { A[i] += A[i-2]; }
			if ( i >= 3 ) { A[i] += A[i-3]; }
	
		}
		
		cout << ( ( A[N] + 9 ) / 10 + 364 ) / 365 << endl;

	}

}

C++: #include <cstdio>
using namespace std;
int main() {
    int dp[31];
    int n;
    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(true){
        scanf("%d",&n);
        if(n==0) break;
        int day=(dp[n]+9)/10;
        printf("%d\n",(day+364)/365);
    }
    return 0;
}