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;
int n,memo[50][50];
int solve(int dp,int sum);

int main(){
    while(1){
    cin >> n;
    if(n==0)break;
    cout << (solve(0,0)/(365*10))+1 << endl;
    fill(memo[0],memo[49],0);
    }

return 0;
}

int solve(int dp,int sum){
    if(sum==n)return 1;
    else if(sum>n)return 0;
    if(memo[dp][sum]!=0)return memo[dp][sum];
    return memo[dp][sum]=solve(dp+1,sum+1)+solve(dp+1,sum+2)+solve(dp+1,sum+3);
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
  const int N = 30;
  vector<long long> DP;
  DP.push_back(1);
  for (int i = 1; i <= N; i++) {
    int size = static_cast<int>(DP.size());
    long long var = 0;
    if (i - 3 >= 0) var += DP.at(size - 3);
    if (i - 2 >= 0) var += DP.at(size - 2);
    if (i - 1 >= 0) var += DP.at(size - 1);
    DP.push_back(var);
  }

  long long n;
  cin >> n;
  while (n != 0) {
    long long var = DP.at(n);
    int year = ceil(var / 3650.0);
    cout << year << endl;
    cin >> n;
  }
}

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

int s[31] = {} ;
int ans[31] = {} ;

void cal(){
	s[1] = 1 ;
	s[2] = 2 ;
	s[3] = 4 ;
	
	for( int i=4 ; i<=30 ; i++ ){
		s[i] = s[i-1] + s[i-2] + s[i-3] ;
	}
	
	for( int i=1 ; i<=30 ; i++ ){
		ans[i] = s[i] / 3650 ;
		if( s[i] % 3650 > 0 ) ans[i]++ ;
	}
}

int main(){
	
	cal() ;
	
	int n ;
	
	while( cin >> n , n ){
		cout << ans[n] << endl ;
	}
	
return 0 ;
}

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

int funk(int a,int b){
	int c=0;
	if(a==b){
		return 1;
	}else if(a>b){
		return 0;
	}else{
		c+=funk(a+1,b);
		c+=funk(a+2,b);
		c+=funk(a+3,b);
		return c;
	}
	
}
	
	
int main() {
	int n,aa,year;
	while(1){
	cin >> n;
	if(n==0) break;
	aa=funk(0,n);
	year=aa/3650;
	year+=1;
	cout << year << endl;
	}
	return 0;
}

C++: #include <iostream>

int ways(int n)
{
	if (n==1) return 1;
	else if (n==2) return 2;
	else {
		int* DP = new int[n+1];
		DP[0] = 1; DP[1] = 1; DP[2] = 2;
		for (int i=3; i<=n; i++) {
			DP[i] = DP[i-1] + DP[i-2] + DP[i-3];
		}
		int res = DP[n];
		delete[] DP;
		return res;
	}
}

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n==0) break;
		int w = ways(n);
		int d = w / 10;
		if (w%10>0) d++;
		int y = d / 365;
		if (d%365>0) y++;
		std::cout << y << std::endl;
	}
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  for(;;) {
    int n;
    cin >> n;
    if(n == 0) return 0;
    n++;
    vi dp(n);
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;
    for(int i = 3; i < n; i++) {
      dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
    }
    int ans = ceil(dp[n-1], 10);
    ans = ceil(ans, 365);
    cout << ans << 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 = (A[n]+9)/10
		a = (a+364)/365;
	cout << a <<endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  int m[31] = {1,1,2};
  loop(i,3,31)
    m[i] = m[i-1] + m[i-2] + m[i-3];
  while(cin>>n,n)
    cout<<m[i]/3650 + 1 <<endl;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0) break;
		lint dp[35]={},ans;
		dp[1]=1;
		dp[2]=2;
		dp[3]=4;
		if(n>3){
			rep(i,4,n+1){
				dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
			}
		}
		ans=dp[n]/3650;
		if(dp[n]%3650) ans++;
		o(ans);
	}
}

C++: //やるだけ！ではない。(これがやるだけでお菓子の分割がやるだけでないなら考察をショートカットしすぎ。)
//(自分にとってはどっちも難しい＞＜)
#include<iostream>
#define int long long
using namespace std;

int n;
signed main() {
	while(cin >> n) {
		if (n < 1 || n > 30) break;
		int dp[31][31] = {0}, i, j;	//i=登った回数、j=今までに登った段数
		
		dp[0][0] = 1;
		for(i = 0; i < n; i++ ) {
			for(j = 0; j <= n; j++ ) {
				for(int k = 1; k <= 3; k++ ) {
					if ( j + k > n ) break;
					dp[i+1][j+k] += dp[i][j];
				}
			}
		}
		
		int ans = 0;
		for(i = 0; i < 31; i++ ) {
			ans += dp[i][n];
		}
		cout << (ans+(int)3649)/(int)3650 << endl;
	}
	return 0;
}

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

int n, dp[32];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	while (cin >> n, n) {
		memset(dp, 0, sizeof(dp));

		dp[1] = dp[2] = dp[3] = 1;

		for (int i = 1; i < n + 1; ++i) {
			if (i + 3 < n + 1) {
				dp[i + 3] += dp[i];
			}
			if (i + 2 < n + 1) {
				dp[i + 2] += dp[i];
			}
			if (i + 1 < n + 1) {
				dp[i + 1] += dp[i];
			}
		}
		cout << dp[n] / 10 / 365 + 1<< endl;
	}

	return 0;
}

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

typedef long long ll;
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

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

	return 0;

}

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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        vector<long long> dp(n + 1, 0);
        dp[0] = 1;
        for (int i = 1; i <= n; i++) {
            dp[i] += dp[i - 1];
            if (i > 1) dp[i] += dp[i - 2];
            if (i > 2) dp[i] += dp[i - 3];
        }
        int ans = ceil(dp[n] / 3650.0);

        cout << ans << endl;
    }

    return 0;
}