HDU ACM 4847 Wow! Such Doge! 被水题坑了

分析:水题,题目居然这么长,全国邀请赛也有水题?strlen(a)返回的是无符号整形,strlen(a)-4会变为正的很大的数,还被RE了两次,唉!人老了。转换为int即可。

#include<iostream>
using namespace std;

#define N 1000010

int main()
{
	char a[N+10];
	int ans,i;

	ans=0;
	while(gets(a))
	{
		for(i=0;i<strlen(a);i++)
			if(a[i]>='A' && a[i]<='Z')
				a[i]+=32;

		for(i=0;i<=int(strlen(a)-4);i++)
			if(!strncmp(a+i,"doge",4))
				ans++;
	}
	cout<<ans<<endl;
    return 0;
}
时间: 2024-10-05 04:58:48

HDU ACM 4847 Wow! Such Doge! 被水题坑了的相关文章

hdu 4847 Wow! Such Doge! 水题

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4847 统计文本中一共有多少个“Doge” 水题 #include <cstring> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <iostream> #include <cstdio> #includ

hdu 1202The calculation of GPA (简单题+坑)

The calculation of GPA Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18748    Accepted Submission(s): 4331 Problem Description 每学期的期末,大家都会忙于计算自己的平均成绩,这个成绩对于评奖学金是直接有关的.国外大学都是计算GPA(grade point a

HDU 4847 Wow! Such Doge! (注意输入格式!)

Wow! Such Doge! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1628    Accepted Submission(s): 1014 Problem Description Chen, Adrian (November 7, 2013). "Doge Is An Ac- tually Good Internet Me

HDOJ(HDU) 4847 Wow! Such Doge!(doge字符统计)

Problem Description Chen, Adrian (November 7, 2013). "Doge Is An Ac- tually Good Internet Meme. Wow.". Gawker. Retrieved November 22, 2013. Doge is an Internet meme that became popular in 2013. The meme typically con- sists of a picture of a Shi

HDU ACM 1017 A Mathematical Curiosity 水题

分析:水题,但要注意格式. #include<iostream> using namespace std; int core(int n,int m) { int i,j,ans=0; for(i=1;i<n;i++) for(j=i+1;j<n;j++) if((i*i+j*j+m)%(i*j)==0) ans++; return ans; } int main() { int T,t,n,m; bool fg=false; scanf("%d",&T

HDU ACM 1073 Online Judge -&gt;字符串水题

分析:水题. #include<iostream> using namespace std; #define N 5050 char a[N],b[N],tmp[N]; void Read(char p[]) { getchar(); gets(tmp); while(gets(tmp)) { if(strcmp(tmp,"END")==0) break; if(strlen(tmp)!=0) strcat(p,tmp); strcat(p,"\n");

HDU ACM 1035 Robot Motion 简单模拟题

分析:一步步的走,走出矩阵则说明没有环,若走到已经走过的地方,说明有环,按格式输出结果,OK. #include<iostream> using namespace std; #define N 15 int dir[4][2]={-1,0,1,0,0,-1,0,1}; char map[N][N]; int vis[N][N]; char ch[]="NSWE"; int n,m; int id(char c) { int i; for(i=0;i<4;i++) i

HDU ACM 5224 Tom and paper 水题+暴力枚举

分析:因为长和宽都是整数,所以枚举判断是不是整数,再取最小的即可. #include<iostream> #include<cmath> using namespace std; int main() { int min; int a,i,T; ios::sync_with_stdio(false); cin>>T; while(T--) { cin>>a; min=1000000000; for(i=1;i<=sqrt(a);i++) if(a%i=

(KMP 水)Wow! Such Doge! -- hdu -- 4847

http://acm.hdu.edu.cn/showproblem.php?pid=4847 Wow! Such Doge! Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4847 Description Chen, Adrian (November 7, 2013). “Doge Is An Ac- tually Good Inter