Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
117263 | 小徐老师 | 出现k次的字符 | C++ | Wrong Answer | 1 MS | 272 KB | 675 | 2025-04-15 20:09:25 |
#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; }
------Input------
5 aaaaaaf
------Answer-----
a
------Your output-----