7.22 第二场 I love 114514

I love 114514

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 247 Accepted Submission(s): 195

Problem Description

Mr.I loves 114514 very much.

Now Mr.I has a string, if “114514” is a substring of this string, then Xiaoi will also love this string.

Please judge whether Xiaoi loves this string, if Xiaoi loves this string, output “AAAAAA”, otherwise output “Abuchulaile”.

Input

The first line contains an integer T(T ≤ 10) . Then T test cases follow.

Each test case contains a string s(1 ≤ |S| ≤ 105).

Output

For each test case, output a single line contain the answer for the test case.

Sample Input

2
114514
1919810

Sample Output

AAAAAA
Abuchulaile

大概题意

判断所给字符串中有没有114514子串。

思路

直接暴力匹配就可

代码

//
// Created by Black on 2021/7/22.
//

#include <iostream>

using namespace std;
string p = "114514";
string s;
int t;

int main() {
    cin >> t;
    while (t--) {
        cin >> s;
        bool flag = false;
        for (int i = 0; i + p.length() <= s.length(); ++i) {
            if (s.substr(i, p.length()) == p) {
                flag = true;
                break;
            }
        }
        if (flag)
            cout << "AAAAAA" << endl;
        else
            cout << "Abuchulaile" << endl;
    }
    return 0;
}
posted @ 2022-05-28 17:01  嘿,抬头!  阅读(35)  评论(0)    收藏  举报