Codeforces Beta Round #98 (Div. 2) / 137A Postcards and photos (模拟)

Zemax光学设计——单透镜设计 (1)在镜头数据编辑器中面2那一栏中的“曲率半径”栏右侧的方格中单击,弹出“在面2上的曲率解”对话框(2)将对话框中的求解类型设为“F数”(3)将“F/#”设置为10设置完成后,其中的一些数据会发生变化在初始结构中,透镜的曲率半径和厚度未知,,这些参数需要软件自动优化得到,但可以使用透镜后表面上边缘厚度解得到近轴焦平面的位置在透镜后表面的厚度上单击鼠标右键,选择边缘光线求解类型,它表示近轴边缘光线会自动在下一个表面上聚焦并确定距离值。 阅读详情

A. Postcards and photos
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 100characters. 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 test(s)
input
CPCPCPC
output
7
input
CCCCCCPPPPPP
output
4
input
CCCCCCPPCPPPPPPPPPP
output
6
input
CCCCCCCCCC
output
2
Note

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).


以now为参考标准进行统计~


完整代码:

/*30ms,0KB*/

#include<cstdio>
#include<cstring>
#include<cmath>

char str[101];

int main()
{
	int count = 0, i = 0;
	scanf("%s", str);
	int len = strlen(str);
	char now = str[0];
	while (i < len)
	{
		int nowcount = 1;
		while (++i < len && str[i] == now)
			++nowcount;
		count += ceil((double)nowcount / 5);
		now = str[i];
	}
	printf("%d", count);
	return 0;
}



嵌入式通讯协议全解析:UART、I2C、SPI、CAN与Modbus实战指南 通讯协议是嵌入式系统设计的核心基础,也是面试与工程实践中避不开的关键环节。从串口UART的异步收发,到I2C总线寻址与SPI高速全双工传输,再到RS485差分长距离通信、CAN总线多主仲裁机制,以及工业领域事实标准的Modbus RTU协议,每一种技术都对应着特定的应用场景与设计权衡。理解协议背后的物理层原理、时序特征和工程坑点,才能真正解决设备间通信的选型、调试与健壮性问题。本文从基础概念出发,系统梳理各类嵌入式通讯协议的工作机制,并结合实际代码示例与对比表格,帮助开发者在面对面试问题或项目设计时,构建从 阅读详情

相关推荐

基于卷积神经网络的人脸表情识别(JAFFE篇)

1.win10/11操作系统2.python3.7以上3.tensorflow2.4以上版本(2.0其它版本需要微调)4.内存12G,显卡4G以上(没有独显倒是也能跑...)(这个可爱的妹子就是JAFFE数据集中的图片)

小林同学的计算机学习 5913

A. Postcards and photos

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Polycarpus has postcards and photos hung in a row on the wall. H

无知的我 1412

手把手教你用vLLM在昇腾910B上部署Qwen3-Embedding-8B模型(保姆级避坑指南)

本文详细介绍了如何在昇腾910B芯片上使用vLLM推理引擎部署Qwen3-Embedding-8B模型的全流程,包括环境准备、vLLM-ascend定制化安装、模型获取与校验、环境变量配置、服务启动参数优化、性能压测及生产级部署建议。特别针对昇腾生态的开发者,提供了保姆级的避坑指南和实用技巧,帮助实现高效稳定的模型部署。

weixin_28726671的博客 463

D - Postcards and photos

A. Postcards and photos time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp...

weixin_30809333的博客 133

WinClaw安全实战 02|五层纵深防护体系全解析:从原理到实操,打造零风险AI智能体

2026年AI智能体爆发式普及,OpenClaw以27.3万GitHub星标成为现象级工具,但恶意Skill投毒、提示词注入、数据外泄等安全事故频发,国家互联网应急中心、工信部等多部门接连发布风险警示。威努特基于国家关键信息基础设施安全防护经验,打造WinClaw安全版AI智能体,其核心竞争力在于**五层纵深防护体系**。本文从安全痛点切入,通过真实事故案例揭示风险本质,全景解构五层防护的架构设计与技术原理,逐层拆解身份认证、安装审查、消息拦截、执行约束、监控审计的实现逻辑,搭配20+实操演示、对比表格

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 496

OpenClaw实战系列02:企业微信接入完全指南

本文详细介绍了如何将OpenClaw与企业微信对接,实现智能机器人功能。主要内容包括:企业微信侧创建智能机器人或自建应用,获取必要凭证和权限;OpenClaw侧安装配置企业微信插件,设置通信通道;完成双向验证并进行功能测试。文章提供了详细的配置步骤、常见问题排查方法和进阶玩法,帮助用户在30分钟内完成对接。关键点包括:确保URL可访问、Token一致、网关正常运行,以及针对不同部署环境(云服务器/内网)的配置差异。

PeterPan的博客 3811

Postcards and Photos

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...

qq_45067380的博客 504

CoppeliaSim和Python进行无人机联合仿真

CopeeliaSim和Python进行无人机轨迹跟踪联合仿真。首先建立起CoppeliaSim和Python的连接,其次在Python中生成轨迹,CoppeliaSim仿真环境中的无人机进行跟踪,并绘制出轨迹曲线,有每一步详细的教学。

加斯顿工程师的博客 987

从codeforces697B、727B、8A三个字符串类型题中讨论scanf正则表达式的使用

正则表达式的使用能够很好的精简的代码,但是,在这几天的刷题过程中我却发现了它其中有具有一定的局限性。虽然如此,我们还是不得不承认这个一旦用上了,效果还是相当明显的。

ccutyear的博客 891

Qt入门教程【Core篇】singal and slot信号与槽

Qt中信号与槽singal and slot

小鱼酱的博客 2449

zabbix系列:内存VM.MEMORY.SIZE监控之total、free、pused、available 参数说明

free -m buffer是即将要被写入磁盘的,而cache是被从磁盘中读出来的. zabbix Web total:1046/1024=1.02G Available:216/1046=20.65% zabbix参数 total- 总物理内存. free- 可用内存. active- 内存当前使用或最近使用,所以它在RAM中。 inactive- 未使用内存. wired- 被标记为始终驻留在RAM中的内...

NIO4444 5666

codeforces-749【思维】

题目链接:点击打开链接 A. Bachgold Problem time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bachgold prob

_Somethingwill 967

ArcGIS Pro 3.4 二次开发 - 布局

本文介绍了在ArcGIS Pro SDK 3.4和.NET 8环境下操作布局工程项的相关方法。主要内容包括:引用布局工程项和关联布局,在新视图中打开或激活已有布局视图,引用活动布局视图,导入/移除布局工程项,创建基本布局或带参考线的自定义布局,修改布局页面尺寸,以及创建圆形图形元素等操作。重点演示了如何通过CIM(Core Infrastructure Model)进行高级布局配置,并详细说明了圆形图形元素的创建过程,包括几何构建、符号设置和图形生成。所有涉及UI线程的操作都遵循ArcGIS Pro SDK

Winemonk 795

Manacher 算法详解:O(n) 复杂度求最长回文子串

先预处理下:在每个字符的两边都插入一个特殊的符号,比如abba变成#a#b#b#a#,aba变成#a#b#a#(因为Manacher算法只能处理奇数长度的字符串)。同时,为了避免数组越界,在字符串开头添加另一特殊符号,比如$#a#b#a#。 以字符串3212343219为例,处理后变成S[] = "$#3#2#1#2#3#4#3#2#1#9#"。 然后用一个数组Len[i]来记录以字符S[i

AC,∑ndless 4609

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

Codeforces Round #119 (Div. 2) / 189A Cut Ribbon (完全背包)

A. Cut Ribbon http://codeforces.com/problemset/problem/189/A time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output

AC,∑ndless 2675

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Codeforces Round #105 (Div. 2) / 148A Insomnia cure (枚举 || 数论)

A. Insomnia cure http://codeforces.com/problemset/problem/148/A time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output

AC,∑ndless 2453

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

Codeforces Beta Round #74 (Div. 2) / 90B African Crossword (模拟)

B. African Crossword http://codeforces.com/problemset/problem/90%2FB time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard o

AC,∑ndless 2416

Codeforces Round #173 (Div. 2) / 282A Bit++(模拟)

A. Bit++ http://codeforces.com/problemset/problem/282/A time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output

AC,∑ndless 2227

Codeforces Round #235 (Div. 2) / 410D Roman and Numbers (带有整除性质的数位DP)

http://codeforces.com/problemset/problem/401/D 解释全部在代码的注释中: /*78ms,205464KB*/ #include using namespace std; const int mx = 1 << 18; long long dp[mx][100]; ///dp[mask][j]表示余数为j时的mask对应的x的个数 ///

AC,∑ndless 2198

Codeforces Round #194 (Div. 1) / 333A Secrets(贪心)

A. Secrets http://codeforces.com/contest/333/problem/A time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ge

AC,∑ndless 2041

Codeforces Round #177 (Div. 1) / 288A Polo the Penguin and Strings(贪心)

A. Polo the Penguin and Strings http://codeforces.com/problemset/problem/288/A time limit per test 2 seconds memory limit per test 256 megabytes input standard input output

AC,∑ndless 1932

Codeforces Beta Round #75 (Div. 2) / 92B Binary Number(贪心)

B. Binary Number http://codeforces.com/problemset/problem/92/B time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output

AC,∑ndless 1931

Codeforces Round #183 (Div. 1) / 303A Lucky Permutation Triple (强大的数学&想法题)

http://codeforces.com/problemset/problem/303/A when n is odd, A[i] = B[i] = i when n is even, there is no solution. why? If , then  or just , where S = 0 + 1 + ... + n - 1 = n(n - 1) / 

AC,∑ndless 1915

Codeforces Round #237 (Div. 2) / 404C Restore Graph (构造最短路径树)

http://codeforces.com/contest/404/problem/C 思路:我们构造一颗最短路径树就行了。 若能够构造,边数必然为n-1(样例1的边数可以是两条)。 如何构造?从距离为1的点开始,逐渐往下加边,生成一颗k叉树。若在中间生成了大于k的叉,则输出-1。 完整代码: /*265ms,4436KB*/ #include using namesp

AC,∑ndless 1840

Codeforces Round #186 (Div. 2) / 313B Ilya and Queries (字符串处理)

B. Ilya and Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ilya the Lion wants to help all his fri

AC,∑ndless 1810

【优化&大师级代码欣赏】Codeforces Round #137 (Div. 2) / 222B Cosmic Tables (矩阵)

B. Cosmic Tables http://codeforces.com/problemset/problem/222/B time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output

AC,∑ndless 1782
上一篇: Codeforces Beta Round #75 (Div. 2) / 92B Binary Number(贪心)
下一篇: 【优化】Codeforces Beta Round #1 / 1B Spreadsheets (字符串处理)
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值