HDOJ_2047_阿牛的EOF牛肉串

AC代码:

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

 

posted @ 2018-11-10 09:18  pha创噬  阅读(148)  评论(0编辑  收藏  举报