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

OpenFOAM-v2006重叠网格挖洞问题实战:如何手动修复overset代码中的边缘识别缺陷 本文深入探讨了OpenFOAM-v2006中重叠网格挖洞问题的实战解决方案,重点修复overset代码中的边缘识别缺陷。通过逆向工程解析挖洞决策机制,设计最小侵入式的函数override方案,并建立多级验证体系,有效解决了网格挖洞区域覆盖不全的问题,提升了计算流体动力学模拟的准确性和可靠性。 阅读详情

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



Ubuntu20.04 安装 MATLAB R2023b 常见问题及解决方案 本文提供了Ubuntu20.04系统上安装MATLAB R2023b的完整指南,包括系统要求检查、依赖项安装、详细安装步骤及常见问题解决方案。特别针对GTK模块加载失败、OpenGL图形加速问题和中文显示乱码等常见问题提供了有效解决方法,帮助用户顺利完成安装并优化使用体验。 阅读详情

相关推荐

从机械臂示教到厨房做饭:ACT模仿学习如何让机器人更“人性化”?

本文探讨了ACT(Action Chunking with Transformers)模仿学习技术如何让机器人更“人性化”,特别是在厨房等复杂场景中的应用。通过动作分块(Action Chunking)和时态融合(Temporal Ensemble)技术,机器人能够像人类一样记忆和执行复杂任务,如烹饪。文章还分析了ACT在家庭场景中的落地挑战及其在康复医疗、柔性制造等领域的跨领域应用潜力。

weixin_30613343的博客 255

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

LabVIEW实战:基于DAQmx的实时正弦波生成、采集与波形图动态显示

本文详细介绍了如何使用LabVIEW和DAQmx驱动实现实时正弦波的生成、采集与动态显示。通过USB-6008数据采集卡,结合队列缓冲机制和动态波形图显示技术,构建了一个完整的信号处理系统。文章包含硬件连接、软件配置、任务设置及常见问题排查,适合LabVIEW初学者和硬件控制开发者参考。

weixin_30872337的博客 124

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

hi3519dv500 os04a10输入调试

因该sensor接在soc端的iic6,在驱动中(Hi3519DV500_SDK_V2.0.1.1\smp\a55_linux\source\mpp\cbb\isp\user\sensor\hi3519dv500\omnivision_os04a10\os04a10_sensor_ctl.c)注意总线的选择。mem_process_isolation=1 改为 mem_process_isolation=0。2、OT_MIPI_SET_HS_MODE配置为LANE_DIVIDE_MODE_1。

linus 3165

如何利用PREEvision和MATLAB开发AUTOSAR软件组件

在业界,比较著名的电子电气架构开发工具要属德国Vector公司开发的PREEvision工具了,而MATLAB/Simulink软件是非常高效且实用的基于模型的应用软件开发工具。利用PREEvision与Simulink联合开发AUTOSAR应用软件组件的开发流程有三种,分别是:“自上而下”开发流程(从PREEvision开始),“自下而上”开发流程(从Simulink开始),以及“双向”开发流程。如下图所示,无论哪一种开发流程,PREEvision与Simulink工具都是通过arxml文件进行信息交互的

怿星科技的博客 5396

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

IEC 61850标准协议解读 3.MMS服务

摘要:本文系统介绍了MMS(制造报文规范)的基础知识及其在IEC61850中的应用。首先解析MMS的核心定义、通信流程(带确认/不带确认服务)、虚拟制造设备(VMD)概念及核心对象(域/有名变量等)。重点阐述IEC61850与MMS的映射关系,包括对象分层映射、服务转换规则及数据类型对应。深入分析ASN.1编解码机制,说明MMS PDU的分层结构与解码流程。最后通过典型报文案例(报告服务、控制服务、文件传输等)和通信初始化流程,展示MMS在智能变电站中的实际应用。全文揭示了MMS作为抽象应用层协议如何通过标

张二狗的博客 724

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

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

ccutyear的博客 891

Loki 分布式日志中心服务

分布式日志中心 Loki + Promtail + Grafana

原名又逢乱世。不要放下学习的脚步,毕竟比天天打牌、钓鱼、打游戏更能从内在充实自己。 2353

美特CRM mcc_login.jsp存在SQL注入漏洞

MetaCRM 是一种现代化的客户关系管理(CRM)平台,旨在通过集成和自动化的方式帮助企业管理与客户的关系,提高销售和服务效率。MetaCRM 的功能和特性通常涵盖了多个领域,包括销售、营销、客户服务、数据分析和自动化工具。

缘梦未来的博客 808

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

YOLO11-pose关键点检测:训练实战篇 | 自己数据集从labelme标注到生成yolo格式的关键点数据以及训练教程

教会你如何用自己的数据集转换成对应格式的数据集以及如何训练YOLO11-pose关键点检测

①答疑群聊服务;②YOLO大模型知识问答系统;③计算机视觉论文生成智能体; 5417

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

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

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

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

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

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 Round #218 (Div. 2) / 371B Fox Dividing Cheese (想法题)

http://codeforces.com/contest/371/problem/B 神题必有神解——你能想到这么做吗? /*15ms,0KB*/ #include using namespace std; int op_cnt[6]; int main() { int a, b, ans = 0; cin >> a >> b; for (int n = 2; n <=

AC,∑ndless 1696
上一篇: 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、付费专栏及课程。

余额充值