BZOJ2295我爱你啊

2295: 【POJ Challenge】我爱你啊
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 202 Solved: 140
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
很奇怪的是,这个人是女同学,为什么会收到女生写的情书233
简单模拟。。
附上本蒟蒻的代码:

#include<cstdio>
#include<cstring>
using namespace std;
int T,i,ans=0,tot,j;
char s[100001],h[10]="luvletter";

int read()
{
    int w=0,c=1; char ch=getchar();
    while (ch<'0' || ch>'9')
      {
        if (ch=='-') c=-1;
        ch=getchar();
      }
    while (ch>='0' && ch<='9')
      w=w*10+ch-'0',ch=getchar();
    return w*c;
}

int main()
{
    T=read();
    for (i=1;i<=T;i++)
      {
        tot=ans=0;
        gets(s);
        for (j=0;j<strlen(s);j++)
          if (s[j]==h[tot])
            {
              if (tot==8) ans++;
              tot=(tot+1)%9;        
            }
        printf("%d\n",ans);
      }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值