牛客小白月赛21 I.I love you
题目描述
此时相望不相闻,愿逐月华流照君。
一纸情书,到底蕴含了多少倍的爱情呢?
I love you, not only for what you are, but for what I am when I am with you.
输入描述:
共一行:一封若干个字符的情书(大小写不敏感)。
情书不会超过684594个字符(大写、小写字母)。
输出描述:
共一行:包含一个整数,即iloveyou在情书中作为子序列出现的次数。
由于答案可能很大,请输出对20010905取模后的值。
示例1
输入
IloveyouNotonlyforwhatyouareButforwhatIamWhenIamwithyouIloveyouNotonlyforwhatYouhavemadeofyourselfButforwhatYouaremakingofme
输出
2864
简单dp吧,感觉做过很多次了……
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=20010905;
int main()
{
string s;
cin>>s;
int len=s.length();
ll ans1=0,ans2=0,ans3=0,ans4=0,ans5=0,ans6=0,ans7=0,ans8=0;
for(int i=0;i<len;i++){
if(s[i]=='i' || s[i]=='I') ans1=(ans1+1)%mod;
if (s[i]=='l' || s[i]=='L') ans2=(ans2+ans1)%mod;
if (s[i]=='o' || s[i]=='O') ans3=(ans2+ans3)%mod;
if (s[i]=='v' || s[i]=='V') ans4=(ans3+ans4)%mod;
if (s[i]=='E' || s[i]=='e') ans5=(ans5+ans4)%mod;
if (s[i]=='y' || s[i]=='Y') ans6=(ans6+ans5)%mod;
if (s[i]=='o' || s[i]=='O') ans7=(ans7+ans6)%mod;
if (s[i]=='u' || s[i]=='U') ans8=(ans8+ans7)%mod;
}
cout<<ans8%mod;
return 0;
}