zoukankan      html  css  js  c++  java
  • 牛客小白月赛21

    链接:https://ac.nowcoder.com/acm/contest/3947/I
    来源:牛客网

    时间限制:C/C++ 1秒,其他语言2秒
    空间限制:C/C++ 131072K,其他语言262144K
    64bit IO Format: %lld

    题目描述

    此时相望不相闻,愿逐月华流照君。
    一纸情书,到底蕴含了多少倍的爱情呢?
    I love you, not only for what you are, but for what I am when I am with you.

    输入描述:

    共一行:一封若干个字符的情书(大小写不敏感)。
    情书不会超过684594个字符(大写、小写字母)。

    输出描述:

    共一行:包含一个整数,即iloveyou在情书中作为子序列出现的次数。
    由于答案可能很大,请输出对20010905取模后的值。

     

    输入

    IloveyouNotonlyforwhatyouareButforwhatIamWhenIamwithyouIloveyouNotonlyforwhatYouhavemadeofyourselfButforwhatYouaremakingofme

    输出

    2864

    讲解参照我以前写的一篇博客:https://www.cnblogs.com/jiamian/p/12210899.html

     1 #include <bits/stdc++.h>
     2 typedef long long LL;
     3 const int INF=0x3f3f3f3f;
     4 const double eps =1e-8;
     5 const int mod=1e8;
     6 const int maxn=2e5+10;
     7 using namespace std;
     8 const int MOD=20010905;
     9 
    10 string str1;
    11 string str2="iloveyou";
    12 LL dp[10];
    13 
    14 int main()
    15 {
    16     #ifdef DEBUG
    17     freopen("sample.txt","r",stdin);
    18     #endif
    19     
    20     while(cin>>str1)
    21     {
    22         memset(dp,0,sizeof(dp));
    23         for(int i=0;i<str1.size();i++)
    24         {
    25             str1[i]=tolower(str1[i]);
    26             for(int j=str2.size()-1;j>=0;j--)
    27                 dp[j]=(dp[j]+(str1[i]==str2[j])*(j==0?1:dp[j-1]))%MOD;
    28         }
    29         cout<<dp[str2.size()-1]<<endl;;
    30     }
    31     
    32     return 0;
    33 }

    -

  • 相关阅读:
    1. 命令执行漏洞简介
    3. 从零开始学CSRF
    2. DVWA亲测CSRF漏洞
    使用pt-fifo-split 工具往mysql插入海量数据
    如何打印矩阵
    年轻人,你活着不是为了观察K线做布朗运动
    Python 之匿名函数和偏函数
    Python之闭包
    Python之装饰器
    Python之with语句
  • 原文地址:https://www.cnblogs.com/jiamian/p/12689059.html
Copyright © 2011-2022 走看看