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>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

const int maxn = 500100;
char a[maxn];

const char ch[] = "doge";

int main()
{
    //freopen("in.txt", "r", stdin);

    int ans = 0;
    while(scanf("%s", a) == 1)
    {
        int len = strlen(a);

        int loc = 0;

        for(int i = 0; i < len; i++)
        {
            if(‘A‘ <= a[i] && a[i] <= ‘Z‘)
                a[i] = a[i] - (‘A‘ - ‘a‘);

            if(a[i] == ch[loc])
                loc++;
            else
            {
                loc = 0;
                if(a[i] == ch[loc])
                    loc++;
            }

            if(loc >= 4)
            {
                ans++;
                loc = 0;
            }
        }

    }

    printf("%d\n", ans);

    return 0;
}
时间: 2024-12-16 11:12:52

hdu 4847 Wow! Such Doge! 水题的相关文章

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]>='

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 4847 陕西邀请赛A(水)

HDU 4847 Wow! Such Doge! 题目链接 题意:给定文本,求有几个doge,不区分大小写 思路:水题,直接一个个读字符每次判断即可 代码: #include <stdio.h> #include <string.h> char c; char a[5]; int main() { a[5] = '\0'; int ans = 0; while ((c = getchar()) != EOF) { if (c >= 'a' && c <=

HDU 4893 Wow! Such Sequence! 水线段树

思路: 线段树走起.. 写完这题就退役T^T 单点更新的时候直接找到这个点的最近fib,然后维护当前和 和 fib的和 #include<stdio.h> #include<string.h> #include<iostream> #include<math.h> #include<algorithm> #include<queue> #include<map> #include<set> #include&l

hdu 1999 不可摸数 水题。

不可摸数 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7966    Accepted Submission(s): 2024 Problem Description s(n)是正整数n的真因子之和,即小于n且整除n的因子和.例如s(12)=1+2+3+4+6=16.如果任何数m,s(m)都不等于n,则称n为不可摸数. Input 包

HDU Senior&#39;s Gun (水题)

题意:给n把枪,m个怪兽,每把枪可消灭1怪兽,并获得能量=枪的攻击力-怪兽的防御力.求如何射杀能获得最多能量?(不必杀光) 思路:用最大攻击力的枪杀防御力最小的怪兽明显可获得最大能量.如果每把枪都去射杀刚好1点能量都拿不到的怪物,那简直等于把枪全丢掉. 1 //#pragma comment(linker,"/STACK:102400000,102400000") 2 #include <iostream> 3 #include <stdio.h> 4 #inc

HDU 5590 ZYB&#39;s Biology 水题

ZYB's Biology Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5590 Description ZYB(ZJ−267)在NOIP拿到600分之后开始虐生物题,他现在扔给你一道简单的生物题:给出一个DNA序列和一个RNA序列,问它们是否配对. DNA序列是仅由A,C,G,T组成的字符串,RNA序列是仅由A,C,G,U组成的字符串. DNA和RNA匹配当且仅当每

HDU 5578 Friendship of Frog 水题

Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5578 Description N frogs from different countries are standing in a line. Each country is represented by a lowercase letter. The distance betwee