zoukankan      html  css  js  c++  java
  • HDU 2065 "红色病毒"问题(生成函数)

    Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 8679    Accepted Submission(s): 3525


    Problem Description
    医学界发现的新病毒因其蔓延速度和Internet上传播的"红色病毒"不相上下,被称为"红色病毒",经研究发现,该病毒及其变种的DNA的一条单链中,胞嘧啶,腺嘧啶均是成对出现的。
    现在有一长度为N的字符串,满足一下条件:
    (1) 字符串仅由A,B,C,D四个字母组成;
    (2) A出现偶数次(也可以不出现);
    (3) C出现偶数次(也可以不出现);
    计算满足条件的字符串个数.
    当N=2时,所有满足条件的字符串有如下6个:BB,BD,DB,DD,AA,CC.
    由于这个数据肯能非常庞大,你只要给出最后两位数字即可.
     
    Input
    每组输入的第一行是一个整数T,表示测试实例的个数,下面是T行数据,每行一个整数N(1<=N<2^64),当T=0时结束.
     
    Output
    对于每个测试实例,输出字符串个数的最后两位,每组输出后跟一个空行.
     
    Sample Input
    4 1 4 20 11 3 14 24 6 0
     
    Sample Output
    Case 1: 2 Case 2: 72 Case 3: 32 Case 4: 0 Case 1: 56 Case 2: 72 Case 3: 56
     
    Author
    Rabbit
     
    Source
     
    Recommend
    lcy   |   We have carefully selected several similar problems for you:  2067 2064 2068 2063 2066 
     
     
    生成函数
    对于$A,C$和$B,D$分别构造多项式
    因为是排列问题,所以用指数型生成函数
    下图为mjt大佬的课件,有一部分写错了,大家自己代入推推就好
    最后$x^n$的系数就是答案
    // luogu-judger-enable-o2
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #define int long long 
    const int MAXN = (1 << 21) + 10, mod = 100; 
    inline int read() { 
        char c = getchar(); int x = 0, f = 1;
        while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
        while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x * f;
    }
    int fastpow(int a, int p) {
        int base = 1;
        while(p) {
            if(p & 1) base = (base * a) % mod;
            a = (a * a) % mod;
            p >>= 1;
        }
        return base % mod;
    }
    main() {
        #ifdef WIN32
        freopen("a.in","r",stdin);
        #endif 
        int QwQ = 0;
        while(scanf("%d", &QwQ) && QwQ != 0) {
            int now = 0;
            for(int i = 1; i <= QwQ; i++) {
                int x = read();
                printf("Case %I64d: %I64d
    ", ++now, (fastpow(4, x - 1) + fastpow(2, x - 1)) % mod);
            }
            puts("");
        }
    }

  • 相关阅读:
    修正MYSQL错误数据的一个存储过程
    解决教学平台上文件中存在无扩展名BUG的办法
    使用C#解析XMIND文件格式
    ASPOSE的示例下载地址
    Https所涉及名词及相关后缀名解释
    Https单向认证和双向认证介绍
    转Postman请求Https接口
    About the Apple Captive Network Assistant
    python之numpy的基本使用
    Python Numpy 数组的初始化和基本操作
  • 原文地址:https://www.cnblogs.com/zwfymqz/p/9156944.html
Copyright © 2011-2022 走看看