Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
101741 杨宸熙 出现k次的字符 C++ Accepted 0 MS 276 KB 451 2024-12-16 20:28:57

Tests(10/10):


Code:

#include<iostream> #include<cstring> using namespace std; int main() { char a[2501]; int k=0,b=0,s=0,c=1; cin>>k>>a; b=strlen(a); for(int i=0;i<b;i++){ if(c==k){ cout<<a[i]; return 0; } if(a[i]==a[i+1]){ c++; }else{ c=1; } } if(c==k){ cout<<a[b-1]; }else{ cout<<"No"; } return 0; }