zoukankan      html  css  js  c++  java
  • bzoj 2295: 【POJ Challenge】我爱你啊

    2295: 【POJ Challenge】我爱你啊

    Time Limit: 1 Sec  Memory Limit: 128 MB

    Description

    ftiasch是个十分受女生欢迎的同学,所以她总是收到许多情书。虽然她十分有魅力,然而她却是个低调的人。因此她从来不会告诉别人她到底收到了多少情书。

    ftiasch的好朋友1tthinking想知道她到底收到了多少情书。1tthinking知道,ftiasch每次收到一封情书,就会在日记最后写下一个包含"luvletter"子序列的串。比如现在ftiasch的日记是alduddvdletterflusvletetedr,那么ftiasch可能受到了0、1、2封情书。现在给出一些ftiasch的日记,问对于每篇日记,ftiasch最多可能受到多少的情书。

    某个序列的子序列是从最初序列通过去除某些元素但不破坏馀下元素的相对位置而形成的新序列。參考wikipedia

    Input

    第1行,一个整数 T (0 ≤ T ≤ 100), 日记的数量。

    第2到 T + 1行,ftiasch的日记 (只包含'a'-'z' 和空格, 长度小于100001)

    Output

    第1到T行,一个整数, 最大可能的情书数量。

    Sample Input

    5
    t
    llllluvletterrr
    luvletterlauavalaeatataearaluvletter
    is wzk a famous boy yes buz he always receives a lot of luv letters
    my heart beats her waves at the shore of the world and writes upon it her signature in tears with the words i love thee

    Sample Output

    0
    1
    3
    1
    0

    HINT

    #include<cstdio>
    #include<string>
    #include<cstring>
    #include<algorithm>
    char s[100010],t[]="luvletter";
    int n,l,j,ans;
    int main()
    {
        scanf("%d
    ",&n);
        while(n--)
        {
            gets(s);
            l=strlen(s);
            ans=j=0;
            for(int i=0;i<l;i++)
            {
                if(s[i]==t[j]) j++;
                if(j==9) j=0,ans++;
            }
            printf("%d
    ",ans);
        }
    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    vue首页组件切换
    vue 页面 添加背景音乐
    vue 新闻列表滚动效果
    vuex中的this.$store.commit
    echarts图例的位置及大小,环图中间字
    octotree — 树形展示 Github 项目代码
    D3 GEO应用专题(一):绘制旋转的3D地球
    vue/cli 3.0脚手架搭建vue项目
    微软锁屏壁纸
    Spring Boot构建RESTful API与单元测试
  • 原文地址:https://www.cnblogs.com/lkhll/p/6110894.html
Copyright © 2011-2022 走看看