Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right and removes the objects consecutively. As Polycarpus doesn't want any mix-ups to happen, he will not carry in his hands objects of two different types. In other words, Polycarpus can't carry both postcards and photos simultaneously. Sometimes he goes to the closet and puts the objects there, thus leaving his hands free. Polycarpus must put all the postcards and photos to the closet. He cannot skip objects. What minimum number of times he should visit the closet if he cannot carry more than 5 items?

Input

The only line of the input data contains a non-empty string consisting of letters "С" and "P" whose length does not exceed 100 characters. If the i-th character in the string is the letter "С", that means that the i-th object (the numbering goes from the left to the right) on Polycarpus' wall is a postcard. And if the i-th character is the letter "P", than the i-th object on the wall is a photo.

Output

Print the only number — the minimum number of times Polycarpus has to visit the closet.

Sample Input

Input
CPCPCPC
Output
7
Input
CCCCCCPPPPPP
Output
4
Input
CCCCCCPPCPPPPPPPPPP
Output
6
Input
CCCCCCCCCC
Output
2

Hint

In the first sample Polycarpus needs to take one item to the closet 7 times.

In the second sample Polycarpus can first take 3 postcards to the closet; then 3 more. He can take the 6 photos that are left in the similar way, going to the closet twice.

In the third sample Polycarpus can visit the closet twice, both times carrying 3 postcards. Then he can take there 2 photos at once, then one postcard and finally, he can carry the last 10 photos if he visits the closet twice.

In the fourth sample Polycarpus can visit the closet twice and take there all 10 postcards (5 items during each go).

 #include<stdio.h>
#include<string.h> int main()
{
char CP[];
int num = ,allnum = ,i;
scanf("%s",CP);
for(i = ;i < strlen(CP);i++)//被提醒strlen什么的不要放在里面会加大时间复杂度
{
if(num <= && CP[i] == CP[i+])
num++;
if(num == || CP[i] != CP[i+])
{
allnum++;
num = ;
}
}
printf("%d",allnum);
return ;
}
 

CodeForces 137A的更多相关文章

  1. 水题 CodeForces 137A Postcards and photos

    题目传送门 /* 水! */ #include <cstdio> #include <cstring> #include <algorithm> using nam ...

  2. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  3. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  4. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  5. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  6. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  7. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  8. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  9. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

随机推荐

  1. 如何解决windows 80端口被占用的情况

    window下如果在安装某个软件或者启动tomcat时 会遇到80端口被占用的情况,通过命令 netstat -ano 查看端口被占用情况 找到占用80端口的进程ID,然后我们在任务管理器当中将这个进 ...

  2. O064、NFS Volume Provider(Part III)

    参考https://www.cnblogs.com/CloudMan6/p/5702199.html   今天我们将前一小节中创建的 nfs-vol-xx attach 到Instance c1 上, ...

  3. Scrapy - 第一个爬虫和我的博客

    第一个爬虫 这里我用官方文档的第一个例子:爬取http://quotes.toscrape.com来作为我的首个scrapy爬虫,我没有找到scrapy 1.5的中文文档,后续内容有部分是我按照官方文 ...

  4. ueditor 去掉自动跟随内容的<p><br /></p>

    //编辑器不能为空内容 if (domUtils.isEmptyNode(me.body)) { me.body.innerHTML = ''; ueditor.all.js  删除BR 如果还不行, ...

  5. Bmake

    Bmake is a common makefile framework. Both support native build and cross build. Easy for use, modif ...

  6. Delphi 字段的操作

    樊伟胜

  7. Java编程思想第四版完整中文高清版.pdf

    Java编程思想第四版完整中文高清版.pdf 链接: https://pan.baidu.com/s/1vV5BHF3L-bnaG6WGurdJ_A 提取码: vigy 复制这段内容后打开百度网盘手机 ...

  8. Redis04——Redis常见语法

    Redis语法 1.string select db 选择数据库(0-20) set k v 设置一个数据 set k1 v nx nx仅仅可以新建的时候进行插入数据 set k2 v xx xx仅仅 ...

  9. 异步消息处理机制相关面试问题-intentservice面试问题详解

    IntentService是什么? IntentService是继承并处理异步请求的一个类,在IntentService内有一个工作线程来处理耗时操作,启动IntentService方法和启动传统的S ...

  10. 使用dsoframer演示ppt

    优点: (1)不用直接打开PowerPoint (2)可以嵌入到Form中,那种先打开ppt然后将ppt嵌入到Form中的方式,会先打开PowerPoint 缺点: 很早就停止更新了....  但是没 ...