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 <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]/365+1;
		cout << year << endl;
	}
}

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

int n;
long long dp[39];

long long 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 (true) {
    int n; cin >> n;
    if (n == 0) break;
    for (int i = 0; i <= n; i++) dp[i] = 0;
    dp[0] = 1, dp[1] = 1, dp[2] = 2, dp[3] = 4;
    
    long long ans = rec(n) / 3650;
    if (rec(n) % 3650 != 0) ans++;
    cout << ans << endl;
  }
  
  return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>


using namespace std;

#define Max INT_MAX
#define Inf (INT_MAX/2)
#define Min INT_MIN


#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
// s <= x < g ?
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
// 0 <= x < w && 0 <= y < h ?
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

typedef pair<int, int> P;

int main()
{
    int n;
    long long dp[30] = {0};
    while( cin >> n ){
        if( n == 0 ) { break;}
        rep(i,30){
            dp[i] = 0;
        }
        rep(i,3){
            dp[i] = 1;
        }
        repi(i,0,30){
            if( IN(i-1,0,30) ) { dp[i] += dp[i-1];}
            if( IN(i-2,0,30) ) { dp[i] += dp[i-2];}
            if( IN(i-3,0,30) ) { dp[i] += dp[i-3];}
        }

        //rep(i,30){
        //    cout << dp[i] << ",";
        //}

        long long sum = 0;

        //cout << "dp[29] = " << dp[29] << endl;
        sum = dp[n-1];
        int ans = sum / 3650;
        if( !(sum % 3650 == 0) ) { 
            ans++;
        } 
        cout << ans << endl;
    }
}

C++: 
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <utility>
#include <queue>
#define INF 1000000007

using namespace std;
typedef long long int ll;

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

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

int main() {

    long long int dp[34] = {0};

    dp[0] = 1;

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

    for(int i=0;i<31;i++){
        dp[i] = dp[i]/10;
    }

    while(1){

        int n;

        cin >> n;

        if(n==0) break;

        int ans = dp[n]%365==0 ? dp[n]/365 : dp[n]/365+1;

        cout << ans << endl;

    }


    return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
  int a[31]={1,1,2};//0段目(まだ踏み出してないので1通り),1段目(1段だけなので1通り),2段目(1歩x2か2歩x1で2通り)
  for(int i=3;i<=30;++i) a[i]=a[i-1]+a[i-2]+a[i-3];//i段目にはi-1.i-2,i-3段目から来るはず
  int n;
  while(cin>>n,n) cout<<(a[n]/10/365+1)<<endl;
}

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

using namespace std;
using ll =long long;
using db = double;

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

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

ll n;
ll dp[10001000];


//ここから書き始める
int main()
{
	cout << setprecision(10);
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	for(int i = 3; i < 100100 ; i++){
		dp[i] = dp[i-3] + dp[i-2] + dp[i-1];
	}

	//各段数について求めて、cinで与えられたｎについてのをポンって出せばいい。
	while (cin >> n){
		if(n == 0) return 0;
		ll days = (dp[n] + 9) / 10;
		ll years = (days + 364) / 365 ;
		cout << years << endl;
	}

}

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<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	unsigned long long dp[100];
	dp[0] = 0;
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;
	rep(i,4,40){
		dp[i] = dp[i-1] + dp[i-2] + dp[i-3];	
		//cout << i << ":"  << dp[i] << endl;
	}
	
	rep(i,0,40){
		if(dp[i] % 10 )
			dp[i] = dp[i] / 10 + 1;
		else
			dp[i] = dp[i] / 10;
	}
	
	rep(i,0,40){
		//cout << i << ":" << dp[i] << endl;
	}

	int n;
	while( cin >> n ){
		if( dp[n] % 365 )
			cout << dp[n] / 365 + 1 << endl;
		else
			cout << dp[n] / 365 << endl;
	}

	ret 0;
}

C++: #include<iostream>

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

C++: #include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,ans,i,j,dp[31],MAX,day;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<=30;i++){
			dp[i]=0;
		}
	dp[0]=1;
	MAX=0;
	for(i=0;i<=n;i++){
		for(j=1;j<=3;j++){
			dp[i+j]+=dp[i];
		}
	}
	day=dp[n]/10;
	if(dp[n]%10!=0){
		day++;
	}
	ans=day/365;
	if(day%365!=0){
		ans++;
	}
	printf("%d\n",ans);
	}
	return 0;
}