HDOJ_2046_骨牌方格_大二写

AC代码:

#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main(void)
{
    freopen("in.txt","r",stdin);
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        long long int count,count1,count2;
        for(int i=1;i<=n;i++)
        {
            if(i==1)
            {
                count1 = 1;
                count = count1;
            }
            else if(i==2)
            {
                count2 = 2;
                count = count2;
            }
            else
            {
                count = count1 + count2;
                count1 = count2;
                count2 = count;
            }
        }
        printf("%lld\n",count);
    }
    
    fclose(stdin);
    system("pause");
    return 0;
} 

 

posted @ 2018-11-09 08:00  pha创噬  阅读(93)  评论(0编辑  收藏  举报