当前位置:网站首页>2022.8.8 Exam written in memory (memory)
2022.8.8 Exam written in memory (memory)
2022-08-10 03:20:00 【bj_hacker】
题目
1、write from memory(memory)–800
时间限制: | 空间限制:
题目描述:
There is a string containing only lowercase English letters ,一个整数 ,初始 .
The steps for one operation are as follows:
1.Select three lowercase English letters ;
2.若 ,则使 增加1,重复该步骤直到 或 不与 any of the phases
同.
或 或
Request at least how many operations to enable .
共 组测试数据.
输入格式:
第一行仅有一个正整数 ( ),表示测试数据的组数.
接下来有 组测试数据,One non-empty string per group line ( Contains only lowercase English letters,in all test data 的长度的
和不超过 ).
输出格式:
对于每组测试数据,输出一行一个整数,Indicates at least how many operations.
代码实现
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int t,ans;
char a[maxn];
int cnt[100];
int main(){
scanf("%d",&t);
while(t--){
ans=0;
memset(cnt,0,sizeof(cnt));
scanf("%s",a);
int len=strlen(a);
int op=0;
for(int i=0;i<len;i++){
if(!cnt[a[i]-95]){
if(op+1>3){
memset(cnt,0,sizeof(cnt));
ans++;
op=1;
cnt[a[i]-95]++;
}
else {
op++;
cnt[a[i]-95]++;
}
}
else cnt[a[i]-95]++;
}
if(op)ans++;
printf("%d\n",ans);
}
return 0;
}
边栏推荐
猜你喜欢
随机推荐
【内存管理概述 Objective-C语言】
.Net面试经验总结
what is a microcontroller or mcu
.Net interview experience summary
【QT】QT项目:自制Wireshark
781. 森林中的兔子
按钮倒计时提醒
OpenCV图像处理学习三,Mat对象构造函数与常用方法
月薪35K,靠八股文就能做到的事,你居然不知道
The flask to add and delete
用于X射线光学器件的哈特曼波前传感器
【干货】集成学习原理总结
免费文档翻译软件电脑版软件
FusionCompute产品介绍
C# winform 单选框
what is eabi
GDB之指令基础参数
【Kali安全渗透测试实践教程】第7章 权限提升
grafana9配置邮箱告警
【Kali安全渗透测试实践教程】第8章 Web渗透