# 1030. 母牛生小牛

### define M 1001

using namespace std;
int main()
{
int n,t;
int a[50];
while(~scanf(“%d”,&n)&&n)
{
a[1]=1;
a[2]=1;
a[3]=1;
for(int i=4;i<=n;i++)
a[i]=a[i-1]+a[i-3];
printf(“%d\n”,a[n]);

}
return 0;


}

#include <iostream>
using namespace std;
int main()
{
int cows[51] = { 0,1,1,1,2 };
for (auto i = 5; i <= 50; ++i)
cows[i] = cows[i - 1] + cows[i - 3];
int n;
while (cin >> n)
{
if (n == 0)
break;
cout << cows[n] << endl;
}
return 0;
}


### include

using namespace std;

int cow(int year)
{
if(year>=1&&year<=3)
return 1;
return cow(year-1)+cow(year-3);
}

int main()
{
int year;
for(;;)
{
cin>>year;
if(year==0) break;
cout<<cow(year)<<endl;
}

}

*#include//只能在1到35的范围内使用
void main()
{
int s[100];
int i,k;
int x;
for(i=0;i<100;++i)
{
scanf(“%d”,&s[i]);
if(s[i]==0)
{
break;
}
}
for(k=0;k<i;++k)
{
x=s[k];
grow(x);
}

}

grow(int s)
{
int small[100000]={0};
long long int i,k,year,m;
int n=1;
int big=0;
for(i=1;i<10000;++i)
{
small[i]=1;
}

for(year=0;year<s;++year)       //此处为核心算法。。比较垃圾吧。。
{
for(m=0;m<n;++m)
{
small[m]++;
if(small[m]==4)
{
big++;
}
}
n=n+big;
}
printf("%d\n",n);


}

[em:13] 用数组长度来表示母牛的数目，限于数组长度，只能在n(1-35)内使用。。。[em:05][em:05]

### include

using namespace std;

int main()
{
int n;
while(cin >> n){
if(n == 0){
return 0;
}
if(n >= 1 && n <= 50){
int i;
int num[4] = {0};
num[0] = 1;// 初始化年龄为0的小牛
for(i = 2; i <= n; i++){
num[3] = num[3] + num[2];
num[2] = num[1];
num[1] = num[0];
num[0] = num[3];
}
int sum;
sum = num[0] + num[1] + num[2] + num[3];
cout << sum << endl;
}
}
return 0;
}

hhhhh陈哲。。。。。。。。。。。。哈哈哈哈哈哈哈哈