杭电ACM—-2018母牛的故事
最后更新于:2022-04-01 09:48:05
~~~
#include <iostream>
using namespace std;
int main()
{
int n;
int a[56]={0,1,2,3};
while(cin>>n&&n)
{
switch(n)
{
case 1:
cout<<a[n]<<endl;
break;
case 2:
cout<<a[n]<<endl;
break;
case 3:
cout<<a[n]<<endl;
break;
default:
for(int i=4;i<56;i++)
a[i]=a[i-1]+a[i-3];
cout<<a[n]<<endl;
break;
}
}
}
~~~