HDU - 2018 母牛的故事
#include<cstdio>
typedef long long ll;
ll a[60];
int main()
{
a[1]=1;a[2]=2;a[3]=3;
for(int i=4;i<=56;i++) a[i]=a[i-1]+a[i-3];
int n;
while(scanf("%d",&n)&&n)
printf("%lld\n",a[n]);
return 0;
}
#include<cstdio>
typedef long long ll;
ll a[60];
int main()
{
a[1]=1;a[2]=2;a[3]=3;
for(int i=4;i<=56;i++) a[i]=a[i-1]+a[i-3];
int n;
while(scanf("%d",&n)&&n)
printf("%lld\n",a[n]);
return 0;
}