📄 2018b.cpp
字号:
/*
2018b 母牛的故事
Time Limit : 1000 ms Memory Limit : 32768 K Output Limit : 256 K
GUN C++
*/
#include <iostream.h>
using namespace std;
#define MAX 1000
int main()
{
int n,ca,num[3]={1,2,3},total,pre,pre2,pre3;
while(cin>>n && n!=0)
{
if(n<=3)
{ cout<<num[n-1]<<endl;continue;}
pre=3;pre2=2;pre3=1;
for(ca=4;ca<=n;ca++)
{
total=pre+pre3;
pre3=pre2;
pre2=pre;
pre=total;
}
cout<<total<<endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -