Description
设有一头小母牛,从出生第四年起每年生一头小母牛,按此规律,第N年时有几头母牛?
Input
输入一个整数N。(1≤N≤50)
Output
第N年时母牛的数量
Sample Input
5
Sample Output
3
HINT
#include<stdio.h>
int main()
{
int N;
int f(int n);
scanf("%d",&N);
printf("%d",f(N));
printf("\n");
return 0;
}
int f(int n)
{
int static cow;
if(n==1||n==2||n==3)
cow=1;
else if(n==4)
cow=2;
else cow=f(n-1)+f(n-3);
return cow;
}