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;

typedef unsigned long long int li;

void sort( int *a )
{
    for( int i = 0; i < 2; i++ )
        for( int j = 0; j < 3; j++ )
            if( a[i] > a[j] )
            {
                int temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
}

li factorial( int a )
{
    if( a <= 1 )
        return 1;
    return a * factorial( a - 1 );
}

int main()
{
    int n, m[3];
    
    while( cin >> n )
    {
        if( n == 0 )
            break;

        li sum = 0;
        int a = n / 3, b = n / 2, c = n;

        for( int i = 0; i <= a; i++ )
            for( int j = 0; j <= b; j++ )
                for( int k = 0; k <= c; k++ )
                    if( 3 * i + 2 * j + k == n )
                    {
                        m[0] = i;
                        m[1] = j;
                        m[2] = k;
                        sort(m);
                        li r = 1;
                        for( int p = 0; p < i + j + k - m[2]; p++ )
                            r *= i + j + k - p;
                        sum += r / ( factorial(m[0]) * factorial(m[1]) );
                    }
                        
    
        //cout << sum << endl;

        if( sum % 10 == 0 )
            sum /= 10;
        else
            sum = sum / 10 + 1;
        
        if( sum % 365 == 0 )
            sum /= 365;
        else
            sum = sum / 365 + 1;

        cout << sum << endl;
    }
    return 0;
}

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

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

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }

const long long INF = 1LL << 60;

int main()
{
    while (true) {
        int N;
        cin >> N;
        long long dp[N+1];
        if (N == 0) {
            break;
        }
        rep(i, N+1) dp[i] = 0;
        dp[0] = 1;
        repd(i, 1, N + 1) {
            dp[i] += dp[i-1];
            if (i > 1) dp[i] += dp[i-2];
            if (i > 2) dp[i] += dp[i-3];
        }
        int ans = dp[N] / 3650;
        if (dp[N] % 3650) ans++;

        cout << ans << endl;
    }

    return 0;
}

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


int main(){
        
        int A[128], N;
        A[0] = 1;
        for(int i=1; i<=32; 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)  cout << (((A[N] + 9)/ 10) + 364) / 365 << endl;

}

C++: #include <algorithm>
#include <cmath>
#include <iostream>
#include <stack>

class steps
{
public:
    steps(const std::size_t l)
        :walk_limit_(l), walk_size_(), permutation_size_()
    {
        for(std::size_t i = 0; i < walk_limit_; ++i)
        {
            this->push(1);
        }
    };

    void step()
    {
        while(!this->done())
        {
            this->next();
        }
    }

    std::size_t permutation()const
    {
        return permutation_size_;
    }

private:
    void next()
    {
        if(this->formed())
        {
            ++permutation_size_;
            this->inc();
        }
        else if(this->overflow())
        {
            this->pop();
            this->inc();
        }
        else
        {
            this->push(1);
        }
    }

    void inc()
    {
        if(current_pattern_.empty()){return;}
        if(3 == this->top())
        {
            this->pop();
            if(current_pattern_.empty()){return;}
            this->inc();
        }
        else
        {
            ++this->top();
            ++walk_size_;
        }
    }
    
    void push(const std::size_t p)
    {
        walk_size_ += p;
        current_pattern_.push(p);
    }

    void pop()
    {
        walk_size_ -= current_pattern_.top();
        current_pattern_.pop();
    }

    std::size_t& top()
    {
        return current_pattern_.top();
    }

    bool formed()const
    {
        return walk_limit_ == walk_size_;
    }

    bool overflow()const
    {
        return walk_limit_ < walk_size_;
    }

    bool done()const
    {
        return current_pattern_.empty();
    }

    std::stack<std::size_t> current_pattern_;
    std::size_t walk_limit_;
    std::size_t walk_size_;
    std::size_t permutation_size_;
};

std::size_t permutation(const std::size_t limit)
{
    steps s(limit);
    s.step();
    return s.permutation();
}

std::size_t year(const std::size_t perm)
{
    return std::ceil(static_cast<double>(perm) / 10.0 / 365.0);
}

int main()
{
    for(std::size_t n; std::cin >> n, n != 0;)
    {
        std::cout << year(permutation(n)) << std::endl;
    }
}

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

int n;
long long dp[31];

int main(){
    while(scanf("%d", &n), n){
        memset(dp, 0, sizeof(dp));
        
        dp[0] = 1;
        for(int j = 0; j <= n; ++j){
            for(int i = 1; i <= 3; ++i){
                if(j + i <= n)
                    dp[j + i] += dp[j];
            }
        }
        
        std::cout << dp[n] / 3650 + (dp[n] % 3650 != 0) << std::endl;
    }
    
    return 0;
}

C++: #include<iostream>

using namespace std;

int kei(int n) {
	long int ans;
	if (n == 1)return 1;
	else if (n == 2)return 2;
	else if (n == 3)return 4;
	else
	{
		ans = kei(n - 1) + kei(n - 2) + kei(n - 3);
		return ans;
	}
}



int main() {
	long int N[1000],ans[1000],c=0,c2;
	while (1) {
		cin >> N[c];
		if (N[c] == 0)break;
		ans[c] = kei(N[c]);
		++c;
	}
	c = 0;

	while (true) {
		if (N[c] == 0)break;
		else
		{
			cout << ans[c]<<endl;
			++c;
		}

	}

}

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

using namespace std;

int main() {
  
  int N;
  while(cin >> N && N) {
    int dp[35] = {1};
    for(int i=0; i<N; i++) {
      dp[i+1] += dp[i];
      dp[i+2] += dp[i];
      dp[i+3] += dp[i];
    }
    cout << dp[N]/3650 + (dp[N]%3650?1:0) << endl;
  }
  
  return 0;
}

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

int main()
{
  string s;
  cin >> s;
  cout << num(stoi(strPlus)) <<endl;
  return 0;
}

int num(int n){
  if(n<0)return 0;
  return num(n-1)+num(n-2)+num(n-3);
}

C++: #include <iostream>
#include <queue>
#include <map>
#include <array>

using namespace std;

int stairs[31];

void Solve(){
  stairs[0] = 1;

  for(int i=0; i<30; i++){
	for(int j=1; j<=3; j++){
	  if(i+j >= 31){
		break;
	  }
	  stairs[i+j] += stairs[i];
	}
  }
}

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

  Solve();

  while(1){
	int n;
	cin >> n;
	
	if(n == 0){
	  return 0;
	}
	int years;
	years = (stairs[n]/3650);
	years += (stairs[n]%3650 != 0) ? 1 : 0;
	
	cout << years << endl;
  }
}