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 main(void){

  int dp[31];
  dp[0] = dp[1] = 1;
  // ０段、１段あがる方法は１通り。
  // 実際上がらないという方法はない、計算の都合上dp[0]にも値を入れる。
  dp[2] = 2;
  // ２段あがる方法は２通り。

  for( int i = 3 ; i < 31 ; i++ ){
    dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
    // 一度に３段上れるので i - 1 , i - 2 , i - 3 ,がそれぞれ何通りあるかわかればよい。
    //　i - 1 , i - 2 , i - 3 のそれぞれの段から i 段に上る方法はそれぞれ１通りしかない。
  }
  
  int n;
  while( cin >> n , n){    
    //cout << "何通りか→" << dp[n] << endl;
    cout << dp[n]/10/365 + 1 << endl;
    // １日に１０通り試すので１０で割る。
    // 何年かかるか計算するため３６５で割り、１を加える。
  }
  return 0;
}

C++: #include<cstdio>
int i,n[99];int main(){for(n[1]=1,n[2]=2,n[3]=4,i=4;i-31;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<stdio.h>

int n,i;
int dp[31];
int main(){
  dp[0]=1;
  dp[1]=1;
  dp[2]=2;
  dp[3]=4;
  for(i=4;i<=30;i++){
    dp[i]=dp[i-1]*2-dp[i-4];
  }
  
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    printf("%d\n",(dp[n]+3649)/3650);
  }
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<memory.h>

using namespace std;
int main(){
	int dp[31][31];
	int n;
	while (1){
		cin >> n;
		if (n == 0)break;
		memset(dp, 0, sizeof(dp));
		dp[1][1] = 1;
		dp[1][2] = 1;
		dp[1][3] = 1;
		for (int i = 1; i <= 30; i++){
			for (int i2 = 1; i2 <= 30; i2++){
				if(i2+1<=30)dp[i + 1][i2 + 1] += dp[i][i2];
				if(i2+2<=30)dp[i + 1][i2 + 2] += dp[i][i2];
				if(i2+3<=30)dp[i + 1][i2 + 3] += dp[i][i2];
			}
		}
		int sum = 0;

		for (int i = 0; i < 30; i++){
			sum += dp[i][n];
		}
		cout << sum / 10 / 365 + 1 << endl;
	}
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int dp[110];
int s;
bool flag;
long long int ans;
int solve(int i);
int main(){
  while(1){
    cin >> s;
    memset(dp, 0, sizeof(dp));
    flag = 0;
    if(s == 0) break;
    ans = solve(0);
    ans /= 10;
    if(!ans) flag = 1;
    if(ans % 365) flag = 1;
    ans /= 365;
    if(flag == 1) ans++;
    cout << ans << endl;
  }
}

int solve(int i){
  if(i == s) return 1;
  if(i > s) return 0;
  if(dp[i] > 0) return dp[i];
  return dp[i] = solve(i + 1) + solve(i + 2) + solve(i + 3);
}

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



int main() {
    vector<int> dan;
    vector<int> dp(35,0);
    int N;
    for(int i=0;i<35;i++){
        int tmp;
        cin>>tmp;
        if(tmp==0) break;
        dan.push_back(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:dan){
        cout << dp[i]/10/365+1<<endl;
    }

    return 0;
}

C++: #include <iostream>

using namespace std;
long A[31];
int main(){
  A[0] = 1;
  A[1] = 1;
  A[2] = 2;
  int n;
  while(cin>>n&&n>0){
    for(int i=3;i<=n;++i){
      A[i] = A[i-1]+A[i-2]+A[i-3];
    }
    cout<<A[n]/3650+1<<endl;
  }
  return 0;
}

C++: #include <algorithm>
#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 <bits/stdc++.h>

using namespace std;

int to_n(int n){
	if (n<=1){
		return 1;
	}else if (n==2){
		return 2;
	}
	return to_n(n-3)+to_n(n-2)+to_n(n-1);
}


int main(void)
{
	int in;
	
	while (cin >> in && in){
		cout << (to_n(in)+3649)/3650 << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	int n;
	int ans;
	int dp[35];
	dp[0]=0;
	dp[1]=0;
	dp[2]=1;
	while(cin>>n){
		if(n==0){
			break;
		}
		for(int i=3;i<n+3;i++){
			dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
		}
		if(dp[n+2]%3650==0){
			ans=dp[n+2]/3650;
		}
		else{
			ans=dp[n+2]/3650+1;
		}
		cout<<ans<<endl;
	}
}

C++: #include<stdio.h>
int main()
{
	const int N = 31;
	int n,i,j,s;
	while(scanf("%d",&n),n)
	{
		int a[N][N+3]={1};
		for(i=0;i<n;++i)
		{
			for(j = 0; j < n; ++j)
			{
				a[i+1][j+3] += a[i][j];
				a[i+1][j+2] += a[i][j];
				a[i+1][j+1] += a[i][j];
			}
		}
		for(s=i=0;i<n;++i)s+=a[i][n];
		printf("%d\n", (s/10-1)/365+1);
	}
	return 0;
}

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

int memo[31];

int culc_cmb( int n ){
    if( memo[n] ){
        return memo[n];
    }else{
        /*if( n == 3 ) return 4;
        else if( n == 2 ) return 2;
        else if( n == 1 ) return 1;*/
        return memo[n] = culc_cmb(n-3)+culc_cmb(n-2)+culc_cmb(n-1);
    }
}

int main(){
    memo[3] = 4;
    memo[2] = 2;
    memo[1] = 1;
    int n;
    while( cin >> n, n ){
        int ans;
        if( culc_cmb(n) % (365 * 10) ) ans =  culc_cmb(n) / (365 * 10) + 1;
        else ans =  culc_cmb(n) / (365 * 10);
        cout << ans << endl;
    }
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int a[31]={1,1,2};
  int n;
  loop(i,3,31)a[i]=a[i-1]+a[i-2]+a[i-3];
  while(cin>>n,n)cout<<(a[n]-1)/365/10+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;
    vector<int> dp(35,0);
    int N;
    for(int i=0;i<35;i++){
        int tmp;
        cin>>tmp;
        if(tmp==0) break;
        dan.push_back(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:dan){
        int tmp=dp[i]/3650;
        if(dp[i]%3650!=0) tmp++;
        cout << tmp <<endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int dp[31] = {};
  dp[0] = dp[1] = 1;
  dp[2] = 2;
  for (int i = 3; i <= 30; i++) {
    for (int j = i - 3; j < i; j++) {
      dp[i] += dp[j];
    }
  }
  int n;
  while (cin >> n, n) {
    cout << dp[n] / (10 * 365) + 1 << endl;
  }

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    while(n != 0){
        int a[31] = {};
        a[1] = 1;
        a[2] = 2;
        a[3] = 4;
        for(int i = 4; i < 31; i++){
            a[i] = a[i-1] + a[i-2] + a[i-3];
        }
        cout << ((a[n]/10)/365)+1 << endl;
        cin >> n;
    }
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,m;
	int dp[34] = {0};
	dp[0] = 1;
	rep(i,30)rep(j,3)dp[i+j+1] += dp[i];
	while(cin >> n , n)
		cout << (dp[n]+3649)/3650 << endl;

}