//母牛的故事
//思路:
//total[0]代表0岁母牛
//total[1]代表1岁母牛
//total[2]代表2岁母牛
//total[3]代表成年母牛       
#include <iostream>
using namespace std;
int main()
{
 int n;
 while(cin>>n && (n!=0))
 {
  int total[4]={0};
      total[3] = 1;

  for(int i=0;i<n-1;i++)
  {
   int adult = total[3];
   total[3] += total[2];
   total[2] = total[1];
   total[1] = total[0];
   total[0] = total[3];
  }
  cout<<(total[0]+total[1]+total[2]+total[3])<<endl;
 }
 return 0;
}

相关文章:

  • 2021-08-19
  • 2021-05-05
  • 2021-11-13
  • 2021-07-31
  • 2021-04-27
  • 2021-04-26
  • 2021-07-12
  • 2021-09-26
猜你喜欢
  • 2022-12-23
  • 2021-07-04
  • 2021-06-19
  • 2021-12-10
  • 2022-01-10
  • 2021-12-14
  • 2021-04-04
相关资源
相似解决方案