hdu 2160 母猪的故事

来源:互联网 发布:华为高科java培训真假 编辑:程序博客网 时间:2024/04/29 08:24

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2160

#include<iostream>using namespace std;int Pig( int n ){    if ( n == 1 )        return 1 ;    else if( n == 2 )        return 2;    else        return Pig( n - 1 ) + Pig( n - 2 ) ;}int main(){  int t ;      cin>>t;    while( t -- )    {       int n ;       cin>>n;       cout<<Pig( n )<<endl;    }    return 0;}


原创粉丝点击