• HDOJ_ 2045_不容易系列之(3)—— LELE的RPG难题


    AC代码:

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #define Max 55
    using namespace std;
    long long int a[Max][1005];
    
    void hanshu()
    {
        memset(a,0,sizeof(a));
        int i,j;
        a[1][0]=3;a[2][0]=6;a[3][0]=6;
        for(i=4;i<=Max;i++)
        {
            for(j=0;j<=1000;j++)
                a[i][j]=a[i-1][j]+2*a[i-2][j];
            for(j=0;j<=1000;j++)
            {
                if(a[i][j]>=10)
                {
                    a[i][j+1]+=a[i][j]/10;
                    a[i][j]%=10;
                }
            }
        }
    }
    
    int main(void)
    {
        hanshu();
        freopen("in.txt","r",stdin);
        int n;
        while(scanf("%d",&n)!=EOF)
        {
            int i=1000;
            while(i--)
            {
                if(a[n][i]!=0)
                    break;
            }
            for(i;i>=0;i--)
                printf("%lld",a[n][i]);
            printf("
    ");
        }
        
        fclose(stdin);
        system("pause");ACd
        return 0;
    }


    AC代码(另一种版本):

    #include <iostream>
    #include <cstdio>
    #define Max 55
    using namespace std;
    long long int a[Max];
    /*
    
    int main(void)
    {
        a[1]=3;a[2]=6;a[3]=6;
        for(int i=4;i<=50;i++)
            a[i]=a[i-1]+a[i-2]*2;
        freopen("in.txt","r",stdin);
        int n;
        while(scanf("%d",&n)!=EOF)
        {
            printf("%I64u
    ",a[n]); 
        }
        
    
        fclose(stdin);
        system("pause");
        return 0;
    }
  • 相关阅读:
    c#数据类型
    遮罩层
    图片轮播
    js 获取浏览器高度和宽度值
    bootstrap、jquery
    洛谷P1442 铁球落地 题解
    HDU3016 Man Down 题解
    POJ2892 Tunnel Warfare 题解
    HDU2795 Billboard 题解
    CF920F SUM and REPLACE 题解
  • 原文地址:https://www.cnblogs.com/phaLQ/p/9954804.html
Copyright © 2020-2023  润新知