A. Down the Hatch!
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Everybody knows that the Berland citizens are keen on health, especially students. Berland students are so tough that all they drink is orange juice!

Yesterday one student, Vasya and his mates made some barbecue and they drank this healthy drink only. After they ran out of the first barrel of juice, they decided to play a simple game. All n people who came to the barbecue sat in a circle (thus each person received a unique index bi from 0 to n - 1). The person number 0 started the game (this time it was Vasya). All turns in the game were numbered by integers starting from 1. If the j-th turn was made by the person with index bi, then this person acted like that:

  1. he pointed at the person with index (bi + 1) mod n either with an elbow or with a nod (x mod y is the remainder after dividing x byy);
  2. if j ≥ 4 and the players who had turns number j - 1, j - 2, j - 3, made during their turns the same moves as player bi on the current turn, then he had drunk a glass of juice;
  3. the turn went to person number (bi + 1) mod n.

The person who was pointed on the last turn did not make any actions.

The problem was, Vasya's drunk too much juice and can't remember the goal of the game. However, Vasya's got the recorded sequence of all the participants' actions (including himself). Now Vasya wants to find out the maximum amount of juice he could drink if he played optimally well (the other players' actions do not change). Help him.

You can assume that in any scenario, there is enough juice for everybody.

Input

The first line contains a single integer n (4 ≤ n ≤ 2000) — the number of participants in the game. The second line describes the actual game: the i-th character of this line equals 'a', if the participant who moved i-th pointed at the next person with his elbow, and 'b', if the participant pointed with a nod. The game continued for at least 1 and at most 2000 turns.

Output

Print a single integer — the number of glasses of juice Vasya could have drunk if he had played optimally well.

Sample test(s)
input
4
abbba
output
1
input
4
abbab
output
0
Note

In both samples Vasya has got two turns — 1 and 5. In the first sample, Vasya could have drunk a glass of juice during the fifth turn if he had pointed at the next person with a nod. In this case, the sequence of moves would look like "abbbb". In the second sample Vasya wouldn't drink a single glass of juice as the moves performed during turns 3 and 4 are different.

题目意思 就是改变Vasya的行动,使他能喝更多酒。  就是看他左边3人是不是字母相同。。因为n>=4。。所以什么都不用考虑了。。

因为Vasya是从0开始的。而且j>=4时才有行动。。所以初始时直接从n开始计数

因为题目太水了。。我决定贴python代码

#!/usr/bin/python
n=input()
s=raw_input()
v,t=n,0
while v < len(s):
if s[v-3]==s[v-2]==s[v-1]:t+=1
v+=n
print t

CF 332A Down the Hatch! 超级水题。。不过题目太长了的更多相关文章

  1. CF 1008B Turn the Rectangles(水题+贪心)

    There are n rectangles in a row. You can either turn each rectangle by 90 degrees or leave it as it ...

  2. POJ 2017 No Brainer(超级水题)

    一.Description Zombies love to eat brains. Yum. Input The first line contains a single integer n indi ...

  3. CF 1042A Benches——二分答案(水题)

    题目:http://codeforces.com/problemset/problem/1042/A #include<iostream> #include<cstdio> # ...

  4. CF 1042 A Benches —— 二分答案(水题)

    题目:http://codeforces.com/problemset/problem/1042/A 代码如下: #include<iostream> #include<cstdio ...

  5. SRM 584 第一次玩TopCoder。。。只水题一道。。。

    第一次topcoder,以前老感觉没有资格去做tc,cf什么的,现在已经慢慢接触了. 感觉还可以,还是有让我们这些蒻菜安慰的水题. tc的确很好玩,用客户端比赛,还有各种规则,而且还是只编写一个类提交 ...

  6. Acdream 1111:LSS(水题,字符串处理)

    LSS Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 128000/64000 KB (Java/Others) SubmitStati ...

  7. Poj1298_The Hardest Problem Ever(水题)

    一.Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar eve ...

  8. 11.07图论水题Test

    11.07图论水题Test 题目 描述 做法 \(BSOJ6378\) 在\(i\)位置可以到\(i+a_i\)或\(i+b_i\)求\(1\rightarrow n\)字典序最小路径 判可达性后贪心 ...

  9. 11.06水题Test

    11.06水题比赛 题目 描述 做法 \(BSOJ5150\) 求\(n\)个数两两之差的中位数 二分中位数,双指针判定\(\le x\)差值对数 \(BSOJ5151\) 求树的最大匹配和其个数 来 ...

随机推荐

  1. C控制语句--分支和跳转

    /*C控制语句--分支和跳转*/ /*关键字 if else switch continue break case default goto 运算符:&&(且) ||(或) ?:(三元 ...

  2. 动画云创始人胥克谦&amp;课程格子创始人李天放分享创业经历

    原文地址:http://student.csdn.net/mcd/topic/163587/955044 2014年10月18日在北京科技大学成功举办了CSDN高校俱乐部全国巡讲,现场參会学生有一百余 ...

  3. iOS开发---转换坐标系

    - (void)viewDidLoad { [super viewDidLoad]; // 蓝色 UIView *blue = [[UIView alloc] init]; blue.backgrou ...

  4. Cocos2d-x3.0之路--02(引擎文件夹分析和一些细节)

    关于怎么搭建好开发环境的我就不写了,网上非常多. 那么 我们来看看 引擎文件的文件夹 所谓知己知彼 百战不殆嘛 先说一下setup.py 这个文件是有关配置的python文件,比方我们在进行andro ...

  5. Linux进程和线程的比較

    进程与线程 參考:http://www.cnblogs.com/blueclue/archive/2010/07/16/1778855.html 首先比較Linux进程和线程的创建的差别,以此展开: ...

  6. 我的MYSQL学习心得(十三)

    原文:我的MYSQL学习心得(十三) 我的MYSQL学习心得(十三) 我的MYSQL学习心得(一) 我的MYSQL学习心得(二) 我的MYSQL学习心得(三) 我的MYSQL学习心得(四) 我的MYS ...

  7. API接口开发简述示例

    作为最流行的服务端语言PHP(PHP: Hypertext Preprocessor),在开发API方面,是很简单且极具优势的.API(Application Programming Interfac ...

  8. 对web.config的ConnectionString加密

    原文:对web.config的ConnectionString加密 本文参考了wayshan的博客,原文地址:http://www.cnblogs.com/wayshan/archive/2012/0 ...

  9. 大约Android 3.0后AsyncTask默认的单线程分析

    在Android下了很大的后台操作在需要的情况下.通常用于AsyncTask这个类.比方说,网络负载形象.访问server接口.一般的情况是使用一个的一例AsyncTask对象mTask,复制Asyn ...

  10. IOS开发苹果官方Sample Code及下载地址

    IOS开发苹果官方Sample Code及下载地址 在线浏览地址:https://developer.apple.com/library/ios/navigation/#section=Resourc ...