当前位置:网站首页>洛谷每日三题之第三天(第四天补做)
洛谷每日三题之第三天(第四天补做)
2022-07-17 01:00:00 【小唐同学(๑><๑)】
因为一些原因昨天计划被打乱,今天补上。
目录
P5015 [NOIP2018 普及组] 标题统计
题目描述
凯凯刚写了一篇美妙的作文,请问这篇作文的标题中有多少个字符? 注意:标题中可能包含大、小写英文字母、数字字符、空格和换行符。统计标题字 符数时,空格和换行符不计算在内。
输入格式
输入文件只有一行,一个字符串 ss。
输出格式
输出文件只有一行,包含一个整数,即作文标题的字符数(不含空格和换行符)。
输入输出样例
输入 #1复制
234输出 #1复制
3输入 #2复制
Ca 45输出 #2复制
4说明/提示
【输入输出样例 1 说明】
标题中共有 3 个字符,这 3 个字符都是数字字符。【输入输出样例 2 说明】 标题中共有55 个字符,包括 11 个大写英文字母, 11 个小写英文字母和 22 个数字字符, 还有 11 个空格。由于空格不计入结果中,故标题的有效字符数为 44 个。
【数据规模与约定】
规定 |s|∣s∣ 表示字符串 ss 的长度(即字符串中的字符和空格数)。
对于 40\%40% 的数据,1 ≤ |s| ≤ 51≤∣s∣≤5,保证输入为数字字符及行末换行符。
对于 80\%80% 的数据,1 ≤ |s| ≤ 51≤∣s∣≤5,输入只可能包含大、小写英文字母、数字字符及行末换行符。
对于 100\%100% 的数据,1 ≤ |s| ≤ 51≤∣s∣≤5,输入可能包含大、小写英文字母、数字字符、空格和行末换行符。
# include <bits/stdc++.h>
using namespace std;
int main()
{
string n;
getline(cin,n);
int l=n.length();
int u=0;
for(int i=0;i<l;i++)
{
if(n[i]>='0'&&n[i]<='9')
{
u++;
// cout<<"数字"<<endl;
}
if(n[i]>='a'&&n[i]<='z')
{
u++;
//cout<<"小写字母"<<endl;
}
if(n[i]>='A'&&n[i]<='Z')
{
//cout<<"大写字母"<<endl;
u++;
}
}
cout<<u;
}P5734 【深基6.例6】文字处理软件
题目描述
你需要开发一款文字处理软件。最开始时输入一个字符串作为初始文档。可以认为文档开头是第 00 个字符。需要支持以下操作:
1 str:后接插入,在文档后面插入字符串 \texttt{str}str,并输出文档的字符串。
2 a b:截取文档部分,只保留文档中从第 aa 个字符起 bb 个字符,并输出文档的字符串。
3 a str:插入片段,在文档中第 aa 个字符前面插入字符串 \texttt{str}str,并输出文档的字符串。
4 str:查找子串,查找字符串 \texttt{str}str 在文档中最先的位置并输出;如果找不到输出 -1−1。为了简化问题,规定初始的文档和每次操作中的 \texttt{str}str 都不含有空格或换行。最多会有 qq 次操作。
输入格式
第一行输入一个正整数 qq,表示操作次数。
第二行输入一个字符串 \texttt{str}str,表示最开始的字符串。
第三行开始,往下 qq 行,每行表示一个操作,操作如题目描述所示。
输出格式
一共输出 nn 行。
对于每个操作 1,2,31,2,3,根据操作的要求输出一个字符串。
对于操作 44,根据操作的要求输出一个整数。
输入输出样例
输入 #1复制
4 ILove 1 Luogu 2 5 5 3 3 guGugu 4 gu输出 #1复制
ILoveLuogu Luogu LuoguGugugu 3说明/提示
数据保证,1 \leq q\le 1001≤q≤100,开始的字符串长度 \leq 100≤100。
# include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
string s0;
cin>>s0;
int m;
string s1;
for(int i=0;i<n;i++)
{
cin>>m;
switch(m)
{
case 1 :
cin>>s1;
s0.append(s1);
cout<<s0<<endl;
break;
case 2 :
int a,b;
cin>>a>>b;
s0=s0.substr(a,b);
cout<<s0<<endl;
break;
case 3 :
cin>>a;
cin>>s1;
s0.insert(a,s1);
cout<<s0<<endl;
break;
case 4 :
cin>>s1;
int y=s0.find(s1);
cout<<y<<endl;
break;
}
}
} P1765 手机
题目描述
一般的手机的键盘是这样的:
要按出英文字母就必须要按数字键多下。例如要按出
x就得按 9 两下,第一下会出w,而第二下会把w变成x。0 键按一下会出一个空格。你的任务是读取若干句只包含英文小写字母和空格的句子,求出要在手机上打出这个句子至少需要按多少下键盘。
输入格式
一行句子,只包含英文小写字母和空格,且不超过 200 个字符。
输出格式
一行一个整数,表示按键盘的总次数。
输入输出样例
输入 #1复制
i have a dream输出 #1复制
23说明/提示
NOI 导刊 2010 普及(10)
# include <bits/stdc++.h>
using namespace std;
int main()
{
int count=0;
string a;
getline(cin,a);
int l=a.length();
for(int i=0;i<l;i++)
{
if(a[i]=='a'||a[i]=='d'||a[i]=='g'||a[i]=='j'||a[i]=='m'||a[i]=='p'||a[i]=='t'||a[i]=='w'||a[i]==' ')
{
count++;
}
if(a[i]=='b'||a[i]=='e'||a[i]=='h'||a[i]=='k'||a[i]=='n'||a[i]=='q'||a[i]=='u'||a[i]=='x')
{
count=count+2;
}
if(a[i]=='c'||a[i]=='f'||a[i]=='i'||a[i]=='l'||a[i]=='o'||a[i]=='r'||a[i]=='v'||a[i]=='y')
{
count=count+3;
}
if(a[i]=='s'||a[i]=='z')
{
count=count+4;
}
}
cout<<count;
}边栏推荐
- CorelDRAW cannot be installed. Solution
- Code demonstration of fcos face detection model in openvino
- This is a mathematical problem
- Ncnn mat matrix class
- In depth understanding of machine learning - unbalanced learning: sample sampling technology - [smote sampling method and borderline smote sampling method of manual sampling technology]
- Vscode+ros2 environment configuration
- Visual analysis of ncnn param file and bin model
- Rewrite equals why rewrite hashcode
- Specifications、多表查询基础
- [face recognition] face recognition based on histogram histogram with matlab code
猜你喜欢

Polynomial interpolation fitting (I)

Zabbix6.0 monitors Dell and IBM server hardware through Idrac and imm2
![mysqldump: [Warning] Using a password on the command line interface can be insecure.](/img/91/8b0d35f85bc0f46daac4e1e9bc9e34.png)
mysqldump: [Warning] Using a password on the command line interface can be insecure.

Leetcode: subsequence problem in dynamic programming

自动装配 & 集合注入

Solve the error of 0x00000709 when win10 connects to the shared printer

367. 有效的完全平方数(入门必会)

Redis和其他数据库的比较
![[MySQL] MHA high availability](/img/d3/d9830f3c331193fd40b8f00ebe35fa.png)
[MySQL] MHA high availability

A Youku VIP member account can be used by several people to log in at the same time. How to share multiple people using Youku member accounts?
随机推荐
D. Permutation restoration (greedy / double pointer /set)
Visual analysis of ncnn param file and bin model
D. Permutation Restoration(贪心/双指针/set)
Polynomial interpolation fitting (II)
通过Dao投票STI的销毁,SeekTiger真正做到由社区驱动
Yolov5 ncnn reasoning
[single chip microcomputer simulation] (XII) instruction system logic operation instruction - logic XOR instruction XRL, accumulator clear 0 and reverse instruction
自动装配 & 集合注入
MySQL log management and full backup incremental backup and recovery
Chengxin University envi_ IDL second week homework: extract aerosol thickness at n points + detailed analysis
Go语言中的Iota关键字怎么使用
Need to slow down a little
Latest installation tutorial of VMware Tools (rhel8)
[MCU simulation] (XIV) instruction system bit operation instructions - bit data transmission instructions MOV, bit variable modification instructions
Authentication code for wireless
Automatic assembly & set injection
Chengxin University envi_ IDL first week experiment test: simple operation of array + detailed analysis
Bisenetv2 face segmentation ncnn reasoning
基于MFC如何实现单个文档的文件读写
RTX3090安装pytorch3D
