比赛 202103省实验桐柏一中普及组联赛 评测结果 AAAAAAAAAA
题目名称 兵马未动,粮草先行 最终得分 100
用户昵称 ZooxTark➲ 运行时间 0.000 s
代码语言 C++ 内存使用 0.33 MiB
提交时间 2021-03-22 20:09:17
显示代码纯文本
#include <iostream>
#include <cstdio>

using namespace std;

char str[20010];

int find_horse(int p)
{
    int ret = 0;
    if(str[p] == 'h' || str[p] == 'H'){p++;
    if(str[p] == 'o' || str[p] == 'O'){p++;
    if(str[p] == 'r' || str[p] == 'R'){p++;
    if(str[p] == 's' || str[p] == 'S'){p++;
    if(str[p] == 'e' || str[p] == 'E'){ret++,p++;
    if(str[p] == 's' || str[p] == 'S'){ret++,p++;
    }}}}}}
    return ret;
}

int main()
{
    freopen("horsesnum.in","r",stdin);
    freopen("horsesnum.out","w",stdout);
    int t = 0,horse = 0;
    char c;
    while(cin >> c)
    {
        if(('A' <= c && c <= 'Z')||('a' <= c && c <= 'z'))
        {
            str[t++] = c;
        }
    }
    int v = 0,x = 0;
    while(v < t)
    {
        horse += x = find_horse(v);
        if(x == 1) v += 5;
        else if(x == 2) v += 6;
        else
        {
            v++;
            while((str[v] != 'h' && str[v] != 'H') && v < t)
                v++;
        }
    }
    cout << horse;
    return 0;
}