#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; }
By signing up a 追梦算法网 universal account, you can submit code and join discussions in all online judging services provided by us.
Using your 追梦算法网 universal account