博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CF 332A Down the Hatch! 超级水题。。不过题目太长了
阅读量:7078 次
发布时间:2019-06-28

本文共 2801 字,大约阅读时间需要 9 分钟。

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 - 1j - 2j - 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
4abbba
output
1
input
4abbab
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/pythonn=input()s=raw_input()v,t=n,0while v < len(s):	if s[v-3]==s[v-2]==s[v-1]:t+=1	v+=nprint t

 

 

转载地址:http://qbpml.baihongyu.com/

你可能感兴趣的文章
一步一步搞定InfoPath(01)——提交表单到Access数据库
查看>>
SET 语句选项
查看>>
ubuntu ufw防火墙
查看>>
Kali 2.0使用SSH进行远程登录
查看>>
类的属性总结
查看>>
在64位Win7下为HP LaserJet 1012安装网络打印机驱动
查看>>
电子邮件地址策略
查看>>
如何快速安装Webmin(linux系统web管理配置工具)
查看>>
PHP带头大哥学习的三部曲!
查看>>
apache忽略文件后缀
查看>>
Makefile 使用总结【转】
查看>>
Linux 基本网络编程
查看>>
ASP.Net 4.0中新增加的23项功能[转]
查看>>
spin_lock、spin_lock_irq、spin_lock_irqsave区别【转】
查看>>
网络翻译实现
查看>>
网络常用的linux系统调用
查看>>
浅谈c#泛型类型变量作为操作数使用的通用解决方法
查看>>
python线程的使用模式
查看>>
beginner项目
查看>>
强制 history 不记住特定的命令
查看>>