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;
typedef long long ll;

int main(){
  
  vector<ll> dp(31);
  dp[0] = 1;
  rep(i,31){
    if(!i) continue;
    dp[i] = dp[i-1];
    if(i>1) dp[i] += dp[i-2];
  	if(i>2) dp[i] += dp[i-3];
  }

  int year = 3650;
  rep(i,31) dp[i] = (dp[i]+year-1)/year; 
  //rep(i,31) cout << i << ":" << dp[i] << endl;
  
  int n; queue<int> q;
  while(cin >> n){
    if(!n) break;
    q.push(n);
  }
  while(!q.empty()){
    int a = q.front();
    cout << dp[a] << endl;
    q.pop();
  }
  return 0;
}

C++: #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

vector<ll> table;

ll dp(ll n)
{
  if(table.at(n)>0) return table.at(n);
  if(n==0) return 1;
  if(n==1) return 1;
  if(n==2) return 2;
  
  table.at(n)=dp(n-1)+dp(n-2)+dp(n-3);
  return table.at(n);
}


int main() 
{
  table=vector<ll>(31,0);
  while(true)
  {
    ll N; cin>>N;
    if(N==0) break;
    cout<<(((dp(N)-1)/10+1)-1)/365+1<<endl;
  } 
  /*
  rep(i,31)
  {
    if(i!=0) cout<<" ";
    cout<<table.at(i);
  }
  cout<<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];
  }
  cout<<dp[n]/3650+1<<endl;
  }
}

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){
		year = A[N]/365+1;
		cout << year << endl;
	}
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string.h>

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

#define pb push_back

using namespace std;

int dp[50];

int main() {
  ascent(i, 1, 30+1) {
    if(i == 1) {
      dp[i] = 1;
    }
    else if(i == 2) {
      dp[i] = 2;
    }
    else if(i == 3) {
      dp[i] = 4;
    }
    else {
      dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
    }
  }

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

C++: #include <iostream>

#define MAX_N 30
#define INF -1

int memo[MAX_N], ans, n;

inline
void solve();

int dp(int a);

inline
int answer(int in);

int main(){
    while(true){
        std::cin >> n;
        
        if(n == 0)
            break;
        
        for(int i = 0; i < MAX_N; ++i)
            memo[i] = INF;
        
        solve();
        
        std::cout << answer(ans) << std::endl;
    }
    return 0;
}

inline
void solve(){
    ans = dp(n + 1);
    return;
}

int dp(int a){
    if(a < 1) return 0;
    if(a == 1) return 1;
    
    if(memo[a] == INF){
        memo[a] = dp(a - 1) + dp(a - 2) + dp(a - 3);
        return memo[a];
    }
    
    return memo[a];	
}

inline
int answer(int in){
    return in % 3650 > 0 ? in / 3650 + 1 : in / 3650;
}

C++: #include <iostream>

#define MAX_N 30
#define INF -1

int memo[MAX_N], ans, n;

void solve();

int dp(int a);

int answer(int in);

int main(){
    while(true){
        std::cin >> n;
        
        if(n == 0)
            break;
        
        for(int i = 0; i < MAX_N; ++i)
            memo[i] = INF;
        
        solve();
        
        std::cout << answer(ans) << std::endl;
    }
    return 0;
}

void solve(){
    ans = dp(n + 1);
    return;
}

int dp(int a){
    if(a < 1) return 0;
    if(a == 1) return 1;
    
    if(memo[a] == INF){
        memo[a] = dp(a - 1) + dp(a - 2) + dp(a - 3);
        return memo[a];
    }
    
    return memo[a];	
}

int answer(int in){
    int count = 1;
    while(true){
        if(count <= 365) break;
        count -= 365;
        ++count;
    }
}

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

int cnt[31];

int main() {
    for(int i=0; i<31; ++i) cnt[i] = 0;
    cnt[0] = 1;
    cnt[1] = 1;
    cnt[2] = 2;

    for(int i=3; i<31; ++i)
        cnt[i] = (cnt[i-1] + cnt[i-2] + cnt[i-3]);
    int y;
    while(cin>>y,y) cout<<cnt[y]/3650+(cnt[y]%3650>=1?1:0)<<endl;
}

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

int A[128], n, a; 
int main() {
	while(cin >> n && n >0){
		A[0] = 0;
		A[1] = 1;
		A[2] = 2;
		for (int i=3; i<=n+10; ++i) {
			A[i] = A[i-1]+A[i-2]+A[i-3];
		}
		a = int((A[n]+9)/10);
		a = int((a+364)/365);
	cout << a <<endl;
	}
}

C++: #include <iostream>

using namespace std;

int main() {
    int n;
    unsigned long long int dp[31];
    while (true) {
        cin >> n;
        if (n == 0) {
            return 0;
        }
        dp[0] = 1;
        for (int i=1; i<=n; i++) {
            dp[i] = 0;
            if (i >= 3) {
                dp[i] += dp[i-3];
            }
            if (i >= 2) {
                dp[i] += dp[i-2];
            }
            dp[i] += dp[i-1];
        }
        cout << (dp[n]/3650)+(dp[n]%3650 == 0? 0: 1) << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int f(int n){
    if(n == 1) return 1;
    if(n == 2) return 2;
    if(n == 3) return 4;
    return f(n-1) + f(n-2) + f(n-3);
    
    
}

int main(void){
    while(true) {
        int n;
        cin >> n;
        if(n==0) break;
        cout << (f(n) / 3650)+1 << endl;
    }
}

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

int main() {
	int a[30];
	a[0] = 1;
	a[1] = 1;
	a[2] = 2;
	for ( int i = 3; i <= 30; i++ )
		a[i] = a[i - 1] + a[i - 2] + a[i - 3];
	while ( cin >> n ) {
		int n;
		cin >> n;
		if ( n == 0 ) break;
		cout << a[n] << endl;
	}
}

C++: #include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

using namespace std;

long long dp(int a){
	if(a==0) return 1;
	else if(a==1) return 1;
	else if(a==2) return 2;
	else {
	return dp(a-3)+dp(a-2)+dp(a-1);
	}
}

int main() 
{
	int n;
	while(cin >> n , !(n==0))
	{
		long long day = dp(n);
		
		if(day%365==0)
		cout << day/3650 << endl;
		else 
		cout <<day/3650 +1 << endl;
	}
	return 0 ;
}

C++: #include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

using namespace std;

int dp(int a){
	if(a==0) return 1;
	else if(a==1) return 1;
	else if(a==2) return 2;
	else {
	return dp(a-3)+dp(a-2)+dp(a-1);
	}
}

int main() 
{
	int n;
	while(cin >> n , !(n==0))
	{
		int day = dp(n);
		
		if(day%365==0)
		cout << day/3650 << endl;
		else 
		cout <<day/3650 +1 << endl;
	}
	return 0 ;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
int cnt;

int dfs(int nn){
	if(nn==n){cnt++;return 0;}
	else if(nn>n){return 0;}
	dfs(nn+1);
	dfs(nn+2);
	dfs(nn+3);
	return 0;
}

int main(){
	while(cin>>n){
		cnt=0;
		if(!n)break;
	dfs(0);
	cout<<cnt/10/365+1<<endl;
	}
}