Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
78131 sh25_wanghy 连续出现的字符 C++ 通过 1 MS 252 KB 575 2025-12-26 15:23:59

Tests(1/1):


#include <iostream> #include <string> using namespace std; int main() { int k; cin >> k; string str; cin >> str; char result = ' '; int count = 1; for (int i = 1; i < str.length(); ++i) { if (str[i] == str[i - 1]) { count++; if (count == k) { result = str[i]; break; } } else { count = 1; } } if (result != ' ') { cout << result; } else { cout << "No"; } return 0; }


测评信息: