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

利用WI生成无线信道数据 选取DeepMIMO的一个射线追踪场景O1(Outdoor 1)Scenario,工作频率为3.5GHz。有两条街和一个十字路口的户外场景18个基站和超过一百万个用户18个基站(BSs):BS1-BS18.每个基站的高度是8米每个基站的天线阵列是isotropic天线三个统一的x-y用户网格用户的总计数量为:1184923每个用户网格中的第一个用户总是(x,y)坐标最低的用户 所有用户的高度是2m每个用户的每个天线阵列是isotropic天线定义射频追踪场景。 阅读详情

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;
}



学习stm32H7之路开始(STM32H7系列1) 前期准备,HAL库框架 2020.01.07 几个重要的参考网址 1.电子工程世界网 http://tags.eeworld.com.cn/tags/STM32H7 链接: link. 2.转:https://blog.csdn.net/simon223/article/list/2?t=1 链接: link. ———————————————— 版权声明:本文为CSDN博主「Simon223」的原创文章,遵循 CC 4.... 阅读详情

相关推荐

虚拟机VirtualBox下载与安装、安装Ubuntu超详细图文步骤,对一些配置问题也有所写。

自己使用过两款虚拟机,相较于VMware虚拟机来说,virtuabox虚拟机所占内存更小,只有几十兆,且完全开源不收费,里面的功能与VMware基本差不多(在日常开发、学习使用完全够用)。最主要的是,在博主自己使用VMware时经常出错,而virtualbox就更稳定一些,所以这篇是针对virtualbox的安装与一些细节部分。

l1015649309的博客 4万+

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

基于JAVA的GB28181实现之SIP服务核心组件解析

本文深入解析了基于JAVA的GB28181标准中SIP服务的核心组件实现,包括协议栈选择、消息处理引擎、事务管理器等关键技术点。通过实战案例分享海康威视、大华设备的特殊处理技巧,并提供性能优化和常见问题排查指南,帮助开发者高效构建稳定的视频监控系统。

weixin_30892037的博客 270

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

Ferromagnetic soft continuum robots

本文来自机器人领域顶刊,Science Robotics。介绍了一种铁磁软连续体机器人,主要贡献为1)介绍了一个基于磁性微粒和聚合物的软连续体机器人的制造方法,在机器人外表面涂了一层水凝胶,极大地降低了摩擦阻力;2)并研究了在磁场下,不同粒子体积分数下,此机器人的驱动性能;利用手动操控的磁铁,进行了许多实验证明该机器人性能的优异性。 铁磁软连续体机器人 Ferromagnetic soft continuum robots [1] Paper Link Authors: Kim, Yoonho, et al

XU Yangxin的博客 1377

FactoryTool量产神器实战:5分钟搞定多块RK3568板卡并行烧录

本文详细介绍了使用瑞芯微FactoryTool对多块RK3568板卡进行高效并行烧录的实战指南。文章从硬件连接、驱动配置、软件操作到排错技巧,提供了一套完整的量产解决方案,重点阐述了如何利用该工具在5分钟内完成多设备固件烧录,并确保eMMC存储的写入稳定性与效率,大幅提升生产线吞吐量。

b0c1d2的博客 1007

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

ASP.NET Core 6 Web API在IIS上的部署与调试

通过以上步骤和配置,你应该能够成功部署并调试你的ASP.NET Core 6 Web API在IIS上。记住,权限和配置是关键,确保你的环境和应用程序代码都正确设置。希望这篇博客对你部署和解决IIS上的问题有所帮助。

m0_74337424的博客 528

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

数字盲水印嵌入和提取的实现基于小波变换DWT算法

数字盲水印是指在不知道原始图像的情况下,在其上嵌入水印并在后续的提取过程中能够恢复出原始水印的一种技术。本文介绍的数字盲水印嵌入和提取的实现方法基于小波变换DWT算法。具体来讲,DWT将信号或图像进行二次下采样和卷积滤波,使得高频分量的图像信息被集中在一个小区域内,方便进行嵌入和提取操作。其中 a 表示嵌入强度,而 watermark 则是用于嵌入的水印图像,这里我们嵌入的是一个全灰的图像。通过以上的代码,我们可以实现数字盲水印的嵌入和提取,并在一定程度上保护数字图片的版权安全。

HackWhisper的博客 518

TGAT Python:图神经网络中的动态图算法

其中,图神经网络中的动态图算法成为了研究的热点之一。在模型的 forward 方法中,通过循环调用 TGATLayer 实例来进行图神经网络的前向传播。最终,模型返回图中节点的表示向量 output,可以用于图分类等任务。TGAT 算法的核心思想是在节点之间建立注意力连接,以捕捉节点在不同时间步之间的关系。TGAT 算法通过引入注意力机制和时间信息,从而有效地对动态图数据进行建模和分析。通过以上 Python 代码,我们可以方便地构建和训练 TGAT 模型,并在图分类任务中应用它。

2301_79366435的博客 1835

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

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

ccutyear的博客 893

本地 AI 自由!OpenClaw+Ollama 双系统部署教程(Windows/Linux),零成本离线跑大模型

本文详细介绍了如何在Windows和Linux双系统中部署OpenClaw AI助手,并通过Ollama对接本地大模型实现完全离线使用。教程包含环境准备、OpenClaw安装配置、Ollama本地模型部署、系统对接等完整流程,特别强调隐私安全和零Token消耗的优势。针对不同操作系统提供具体命令,并给出常见问题解决方案,即使是新手也能快速搭建专属本地AI助手。最终实现的方案无需联网、无使用成本,且能保障数据隐私安全。

2501_93651177的博客 7240

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 4611

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

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 2676

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

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

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

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 2417

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 2231

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 2199

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 1934

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 1932

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 1916

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、付费专栏及课程。

余额充值
⌂ 换网址