首页 > 其他分享 >hdu 4055

hdu 4055

时间:2023-08-23 10:01:28浏览次数:49  
标签:__ hdu const int 4055 str sizen include


http://acm.hdu.edu.cn/showproblem.php?pid=4055

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
using namespace std;

const int mod=1000000007;
const int sizen=1010;
__int64 dp[sizen][sizen];
__int64 sum[sizen][sizen];
char str[sizen];

int main()
{
    int i,j;
    int len;
    while(scanf("%s",str)!=EOF)
    {
        
        dp[1][1]=sum[1][1]=1;
        len=strlen(str);
        for(i=2;i<=len+1;i++)
            for(j=1;j<=i;j++)
            {
                if(str[i-2]=='I')
                    dp[i][j]=sum[i-1][j-1]%mod;
                if(str[i-2]=='D')
                    dp[i][j]=(sum[i-1][i-1]-sum[i-1][j-1]+mod)%mod;
                if(str[i-2]=='?')
                    dp[i][j]=sum[i-1][i-1];
                sum[i][j]=(dp[i][j]+sum[i][j-1])%mod;
            }
        printf("%I64d\n",sum[len+1][len+1]);
    }
    return 0;
}



标签:__,hdu,const,int,4055,str,sizen,include
From: https://blog.51cto.com/u_16234093/7199351

相关文章

  • hdu 4055 dp
    http://acm.hdu.edu.cn/showproblem.php?pid=4055#include<stdio.h>#include<stdlib.h>#include<string.h>#include<math.h>#include<iostream>#include<algorithm>usingnamespacestd;constintmod=1000000007;cons......
  • hdu 2191 多重背包
    http://acm.hdu.edu.cn/showproblem.php?pid=2191#include<stdio.h>#include<stdlib.h>#include<string.h>#include<math.h>#include<iostream>#include<algorithm>usingnamespacestd;structele{intprice;......
  • 「HDU1166」敌兵布阵
    前言题目好多废话大意有一个序列,开始时每一位都有一个值,然后是若干个命令:Addij,表示第\(i\)位增加\(j\);Subij,表示第\(i\)位减少\(j\);Queryij,表示从第\(i\)位到地\(j\)位的总和;End,表示结束,在每组数据最后出现。思路这题一眼盯真,可以用线段树或者树状数组解决,都是单......
  • 杭电ACM HDU 2816 I Love You Too
    ILoveYouTooTimeLimit:2000/1000MS(Java/Others)   MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):1258   AcceptedSubmission(s):759ProblemDescriptionThisisatruestory.Amanshowedhislovetoagirl,butthegirldi......
  • 杭电ACM HDU 3346 Lucky Number
    LuckyNumberTimeLimit:2000/1000MS(Java/Others)   MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):1523   AcceptedSubmission(s):800ProblemDescriptionToChinesepeople,8isaluckynumber.Nowyourtaskistojudgeifanu......
  • 杭电ACM HDU 2560 Buildings
    BuildingsTimeLimit:2000/1000MS(Java/Others)   MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):1828   AcceptedSubmission(s):1553ProblemDescriptionWedividetheHZNUCampusintoN*Mgrids.Asyoucanseefromthepicturebe......
  • 杭电ACM HDU 3351 Seinfeld
    SeinfeldTimeLimit:2000/1000MS(Java/Others)   MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):1071   AcceptedSubmission(s):540ProblemDescriptionI’moutofstories.ForyearsI’vebeenwritingstories,somerathersilly,......
  • HDU 5012
    DiceTimeLimit:2000/1000MS(Java/Others)    MemoryLimit:65536/65536K(Java/Others)TotalSubmission(s):1465    AcceptedSubmission(s):749InputTherearemultipletestcases.PleaseprocesstillEOF. Foreachcase,thefirstline......
  • hdu 5365
    LCPArrayTimeLimit:4000/2000MS(Java/Others)    MemoryLimit:131072/131072K(Java/Others)TotalSubmission(s):1223    AcceptedSubmission(s):338ProblemDescriptions=s1s2...sn,let suffi=sisi+1...sn bethesuffixstartwith......
  • HDU 5500
    ReordertheBooksTimeLimit:4000/2000MS(Java/Others)    MemoryLimit:131072/131072K(Java/Others)TotalSubmission(s):449    AcceptedSubmission(s):294ProblemDescriptionn(n≤19) booksinthisseries.Everybookhasanumberfrom ......