Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
117264 小徐老师 出现k次的字符 C++ Wrong Answer 1 MS 272 KB 721 2025-04-15 20:09:57

Tests(0/10):


Code:

#include <bits/stdc++.h> using namespace std; int main() { int k; //至少出现了k次 cin >> k; string s; cin >> s; char c = s[0]; int cnt = 0; for(int i = 0; i < s.size(); ++i) { if(s[i] == c) { cnt++; } else { //cout << cnt << endl; if(cnt == k) { cout << c << endl; return 0; } else { c = s[i]; cnt = 1; } } } if(cnt == k) { cout << c << endl; return 0; } cout << "No" << endl; return 0; }


Run Info:

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