蓝桥杯之母牛的故事

AC代码:

#include <iostream>
#include <cstdio>
using namespace std;
int n;
int main(void)
{
	freopen("in.txt","r",stdin);
	while(scanf("%d",&n)!=EOF&&n)
	{
		long long i1=0,i2=0,i3=0,i4=1,tmp;
		n=n-1;
		while(n)
		{
			i4+=i3;
			i3=i2;
			i2=i1;
			i1=i4;
			n--;
		}
		
		printf("%lld\n",i1 + i2 + i3 + i4);
	}
	
	fclose(stdin);
	return 0;
} 

 

posted @ 2019-02-26 20:38  pha创噬  阅读(202)  评论(0编辑  收藏  举报