杭电ACM----2018母牛的故事

#include <iostream>
using namespace std;
int main()
{
    int n;
    int a[56]={0,1,2,3};
    while(cin>>n&&n)
    {
        switch(n)
        {
            case 1:
                cout<<a[n]<<endl;
                break;
            case 2:
                cout<<a[n]<<endl;
                break;
            case 3:
                cout<<a[n]<<endl;
                break;
            default:

                    for(int i=4;i<56;i++)
                    a[i]=a[i-1]+a[i-3];
                    cout<<a[n]<<endl;

                    break;

        }
    }

}


posted @ 2013-04-07 19:45  javawebsoa  Views(223)  Comments(0Edit  收藏  举报