Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
109630 陈铎文 出现k次的字符 C++ Wrong Answer 1 MS 280 KB 648 2025-02-10 09:09:59

Tests(0/10):


Code:

#include<bits/stdc++.h> using namespace std; int main() { char a[301]; // 定义字符数组 int k; cin >> k; cin >> a; int n = strlen(a); bool t = false; for (int i = 0; i <= n - k; i++) { bool match = true; for (int j = 1; j < k; j++) { if (a[i] != a[i + j]) { match = false; break; } } if (match) { for (int j = 0; j < k; j++) { cout << a[i + j]; t = true; break; } } } if (!t) { cout << "No"; } return 0; }


Run Info:

------Input------
5 aaaaaaf
------Answer-----
a
------Your output-----
aa