#include <iostream>
#include <string.h>
#include <ctype.h>
using namespace std;
int main()
{
int k;
char str[100000];
memset(str,0x0,sizeof(str));
int countt[100000] = {1, 0};
int index = 0;
cin>>k;
cin>>str;
for( int i=1 ; i<strlen(str) ; i++)
{
if( islower(str[i]) != islower(str[i-1]) )
{
index++;
}
countt[index]++;
}
int len = 0;
int maxlen = 0;
for( int i=0 ; i<=index ; i++ )
{
if( countt[i] == k)
{
len+=k;
if( len > maxlen )
{
maxlen = len;
}
}
if( countt[i]>k )
{
len+=k;
if( len > maxlen )
{
maxlen = len;
}
len = k;
}
if( countt[i] < k)
{
if( len > maxlen )
{
maxlen = len;
}
len = 0;
}
}
cout<<maxlen;
return 0;
}
#include
#include
#include
using namespace std;int main()
{int k;
char str[100000];
memset(str,0x0,sizeof(str));
int countt[100000] = {1, 0};
int index = 0;cin>>k;
cin>>str;for( int i=1 ; i {
if( islower(str[i]) != islower(str[i-1]) )
{
index++;
}countt[index]++;
}int len = 0;
int maxlen = 0;for( int i=0 ; i<=index ; i++ )
{
if( countt[i] == k)
{
len+=k;
if( len > maxlen )
{
maxlen = len;
}
}if( countt[i]>k )
{
len+=k;if( len > maxlen )
{
maxlen = len;
}len = k;
}if( countt[i] < k)
{
if( len > maxlen )
{
maxlen = len;
}len = 0;
}
}cout<
return 0;
}
c++程式碼(標題沒打好)