http://codeforces.com/contest/978/problem/B
解题思路:
1.不能出现"xxx"这样的串,贪心删掉多余的x就好了
2.遍历一遍字符串,遇到 'x' 计数器++,计数器大于等于3表示要删掉一个'x',遇到非'x'就令计数器清零
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String str = sc.nextLine();
str = sc.nextLine();
int cnt = 0,ans = 0;
for(int i = 0;i < str.length();i++) {
if(str.charAt(i) == 'x') cnt++;
else cnt = 0;
if(cnt >= 3) ans++;
}
System.out.println(ans);
}
}