BZOJ 2295: [POJ Challenge]我爱你啊
由于是子序列,那么难度就在于读入
#include<cstdio> #include<algorithm> #include<cstring> using namespace std; char s[9]={'l','u','v','l','e','t','t','e','r'}; int main(){ int T; scanf("%d",&T); char c=getchar(); while (T--){ int ID=0,ans=0; char c='-'; while (c!='\n'){ c=getchar(); if (c==s[ID]) ID++; if (ID==9) ans++,ID=0; } printf("%d\n",ans); } return 0; }