链接:https://ac.nowcoder.com/acm/contest/3947/I
来源:牛客网
输入描述:
共一行:一封若干个字符的情书(大小写不敏感)。
情书不会超过684594个字符(大写、小写字母)。
输出描述:
共一行:包含一个整数,即iloveyou在情书中作为子序列出现的次数。
由于答案可能很大,请输出对20010905取模后的值。
IloveyouNotonlyforwhatyouareButforwhatIamWhenIamwithyouIloveyouNotonlyforwhatYouhavemadeofyourselfButforwhatYouaremakingofme
2864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int mod=20010905;
int dp[8];
int main()
{
string str;
cin>>str;
for(int i=0; i<str.size(); i++)
{
str[i]=tolower(str[i]);
if(str[i]=='i')dp[0]++;
if(str[i]=='l')dp[1]=(dp[1]+dp[0])%mod;
if(str[i]=='o')dp[2]=(dp[1]+dp[2])%mod;
if(str[i]=='v')dp[3]=(dp[3]+dp[2])%mod;
if(str[i]=='e')dp[4]=(dp[4]+dp[3])%mod;
if(str[i]=='y')dp[5]=(dp[5]+dp[4])%mod;
if(str[i]=='o')dp[6]=(dp[6]+dp[5])%mod;
if(str[i]=='u')dp[7]=(dp[7]+dp[6])%mod;
}
cout<<dp[7];
}