zoukankan      html  css  js  c++  java
  • 模拟_简单模拟处理边界(HDU_2525)

    这题做起来有些烦躁,可能是题意没有理解清楚吧。

    题意:造出来的士兵第一天没有攻击力,但可以采样,且要消耗一天的生命,共 d 天生命。造一个士兵需要 k 天,k + 1 天时可以有攻击力,造到 k 天时相当于成活士兵的第一天。刚开始的士兵为第一天的士兵,没有攻击力,但可以采样。总共模拟 x 天。数据较大,采用 __int64。

    ps: 这题应该有数学公式,但难的推导,直接模拟了。

    #include <stdio.h>
    #include <string.h>
    
    #define M 102
    
    int n,d,k,a,x;
    __int64 live[M],grow[M],all;
    
    void add_day()
    {
        __int64 A = 0;
        live[0] = grow[k];
        for(int i=d; i>0; i--)
        {
            all += live[i] * 5;
            if(i <= a)
                A += live[i];
            live[i] = live[i-1];
        }
        for(i=k; i>1; i--)
        {
            grow[i] = grow[i-1];
        }
        grow[1] = A;
    }
    
    int main()
    {
    //    freopen("in.txt","r",stdin);
    
        int t;
        scanf("%d",&t);
        while(t--)
        {
            scanf("%d%d%d%d%d",&n,&d,&a,&k,&x);
    
            memset(live,0,sizeof(live));
            memset(grow,0,sizeof(grow));
            all = 0;
            live[1] = n;
            while(x--)
            {
                add_day();
            }
            printf("%I64d
    ",all);
        }
        return 0;
    }
  • 相关阅读:
    POJ 2752 Seek the Name, Seek the Fame
    POJ 2406 Power Strings
    KMP 算法总结
    SGU 275 To xor or not to xor
    hihocoder 1196 高斯消元.二
    hihoCoder 1195 高斯消元.一
    UvaLive 5026 Building Roads
    HDU 2196 computer
    Notions of Flow Networks and Flows
    C/C++代码中的笔误
  • 原文地址:https://www.cnblogs.com/lk1993/p/3258911.html
Copyright © 2011-2022 走看看