Problem description has a cow. It has a young cow every year. Starting from the fourth year, each calf also gave birth to a calf at the beginning of each year. How many cows are there during the nth year of programming? The input data is composed of multiple test instances. Each test instance occupies one row and contains an integer N (0 <n <55). The meaning of N is described in the question.
N = 0 indicates the end of the input data without processing. For each test instance, output outputs the number of cows in the nth year.
Each output occupies one row. Sample input2450sample output246 code:
# Include <stdio. h>
Int main ()
{
Int N, S [100], I, sum;
While (scanf ("% d", & N )! = EOF & (n! = 0 ))
{
S [0] = s [1] = s [2] = 0;
S [3] = 1;
For (I = 1; I <n; I ++)
{
S [3] = s [3] + s [2];
S [2] = s [1];
S [1] = s [0];
S [0] = s [3];
}
Sum = s [0] + s [1] + s [2] + s [3];
Printf ("% d \ n", sum );
}
Return 0;
}