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. Centos7:nginx的安装,配置及使用

    安装依赖 yum install gcc-c++//gcc环境 yum install -y pcre pcre-devel//PCRE:nginx的http模块使用pcre来解析正则表达式 yum ...

  2. 【Swift后台】背景介绍

    在2017年11月的时候,就已经对Swift后台进行过研究,简书上发表过相应文章,那时候发表的是单纯的对Vapor文档的翻译,此次则是作为进一步研究的学习笔记来保存. Swift后台的本质,主要是Va ...

  3. Sublime Text 3:自定义语法高亮

    (http://ilkinulas.github.io/programming/2016/02/05/sublime-text-syntax-highlighting.html) 要安装"P ...

  4. C# 基础 字符串 集合 文件操作

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  5. 获取iframe子页面内容高度给iframe动态设置高度

    <!DOCTYPE html><html> <head> <meta charset="UTF-8" /> <meta nam ...

  6. python自学笔记之开源小工具:SanicDB介绍

    SanicDB 是为 Python的异步 Web 框架 Sanic 方便操作MySQL而开发的工具,是对 aiomysql.Pool 的轻量级封装.Sanic 是异步IO的Web框架,同时用异步IO读 ...

  7. vue中 localStorage的使用方法(详解)

    vue中实现本地储存的方法:localStorage,在HTML5中,新加入了一个localStorage特性,这个特性主要是用来作为本地存储来使用的,解决了cookie存储空间不足的问题(cooki ...

  8. 第三方库-正则re

    Python正则表达式里的单行re.S和多行re.M模式 Python 的re模块内置函数几乎都有一个flags参数,以位运算的方式将多个标志位相加.其中有两个模式:单行(re.DOTALL, 或者r ...

  9. Vim——替换命令

     原创声明:本文系博主原创文章,转载或引用请注明出处. 1. 文本替换 #替换每一行的第一个a :%s/a/b/ #全部替换 :%s/a/b/g #替换/时需要转义"\/" 2. ...

  10. solr admin界面的监控

    这里可以看到,solr的版本,lucene的版本,jvm的版本,CPU核数,jvm启动参数,还有物理内存占用,交换空间占用,jvm内存占用. 这里可以看到每个core的情况. 这里可以看到java的所 ...