Top

HDU - 4847 - Wow! Such Doge!(暴力)


博主链接

题目链接

题面太长了,就不上题目截图了QAQ

题意:

在给出的段落里面找出“doge”出现的次数,大小写都可以。(超级大水题,就考你输入恶心恶心人)

题解:

直接暴力求每一句话出现的doge次数(大小写不限),在一块就可以了输入格式处理—-把类似于“Wow! Such Dooooooooooooooge!!!“这种一行输入看出多个字符串输入,这里看成三个字符串,所以直接用%s存,存一个处理一个

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h>
#include<string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+21;
const int mod=1e9+7;
char s[maxn];
int ans=0;
int main(){
while(scanf("%s",s)!=EOF){
int len=strlen(s);
if(len<3)continue;
for(int i=0;i<len-3;i++){
if((s[i]=='d'||s[i]=='D')&&(s[i+1]=='o'||s[i+1]=='O')&&(s[i+2]=='g'||s[i+2]=='G')&&(s[i+3]=='e'||s[i+3]=='E')){
ans++;
i+=3;
}
}
}
printf("%d\n",ans);
return 0;
}


未经允许不得转载: Anoyer's Blog » HDU - 4847 - Wow! Such Doge!(暴力)