1 solutions

  • 1
    @ 2023-10-30 12:44:40
    #include<stdio.h>
    #include<string.h>
    
    char f[100005];
    
    int main(){
    	
    	int n,k,ans=0;
    	
    	scanf("%d %d",&n,&k);
    	scanf("%s",f);
    	
    	int x=strlen(f);
    	for(int i=0;i<x;++i){
    		if(f[i]=='B'){//遇到坏签就把后面k-1个签跳过,这样能保证全都是好签
    			ans++;
    			i+=(k-1);
    		}
    	}
    	
    	printf("%d",ans);
    	return 0;
    }
    
    • 1

    Information

    ID
    6943
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    9
    Tags
    # Submissions
    344
    Accepted
    28
    Uploaded By