zoukankan      html  css  js  c++  java
  • 2018. The Debut Album

    http://acm.timus.ru/problem.aspx?space=1&num=2018

    真心爱过,怎么能彻底忘掉

    题目大意:

    长度为n的串,由1和2组成,连续的1不能超过a个,连续的2不能超过b个

    dpa[i] 表示长度为i时以a为结尾的串的个数,dpb[i] 类似

    求dpa[i]时 需要枚举结尾a的个数就可以了 dpb[i] 类似

    #include <iostream>
    #include <stdio.h>
    #include <stdlib.h>
    #include <io.h>
    #include <string.h>
    
    using namespace std;
    
    const int N=50001;
    const int M=301;
    const unsigned int MOD=1000000007;
    unsigned int dpa[N];
    unsigned int dpb[N];
    int main()
    {
        //freopen("data.in","r",stdin);
        memset(dpa,0,sizeof(dpa));
        memset(dpb,0,sizeof(dpb));
        int n,a,b;
        cin>>n>>a>>b;
        dpa[0]=dpb[0]=1;
        for(int i=1;i<=n;++i)
        {
            for(int j=1;j<=a&&j<=i;++j)
            {
                dpa[i]=(dpa[i]+dpb[i-j])%MOD;
            }
            for(int j=1;j<=b&&j<=i;++j)
            {
                dpb[i]=(dpb[i]+dpa[i-j])%MOD;
            }
        }
        cout<<((dpa[n]+dpb[n])%MOD)<<endl;
        return 0;
    }
    

      

  • 相关阅读:
    敏感信息脱敏实现
    SpringBoot集成Swagger2
    CSS三大特性
    background
    background-attachment
    background-position
    background-repeat
    background-image
    background-color
    CSS元素显示模式
  • 原文地址:https://www.cnblogs.com/liulangye/p/4281968.html
Copyright © 2011-2022 走看看