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;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
· 为什么 退出登录 或 修改密码 无法使 token 失效