CF41C Email address 题解
Content
有一个字符串 \(s\),它满足以下要求:
- 只包含
.、@和小写字母。 - 不以
.为开头或者结尾。 - 不以
@为开头或者结尾,并只能包含一个@。
请将其进行如下操作,使得这个字符串长度最小:
- 将子串
dot转化为.。 - 将子串
at转化为@。
数据范围:\(1\leqslant |s|\leqslant 100\)。
Solution
模拟就好,其实不需要什么 STL 里面的高级函数(只有一个 \(\texttt{size}\) 函数)。
首先得要找到子串 \(\texttt{dot}\) 和 \(\texttt{at}\) 的位置,尤其要注意的是 @ 最多只能用一次,所以开个变量判断一下。还有不能够在开头和结尾出现 . 或者 @。
Code
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int atflag;
string s;
int main() {
cin >> s;
int len = s.size();
for(int i = 0; i < len;) {
if(i > 0 && i < len - 3 && s[i] == 'd' && s[i + 1] == 'o' && s[i + 2] == 't') {
printf(".");
i += 3;
} else if(i > 0 && i < len - 2 && s[i] == 'a' && s[i + 1] == 't' && !atflag) {
printf("@");
i += 2;
atflag = 1;
} else {
printf("%c", s[i]);
++i;
}
}
return 0;
}
CF41C Email address 题解的更多相关文章
- 转载:邮箱正则表达式Comparing E-mail Address Validating Regular Expressions
Comparing E-mail Address Validating Regular Expressions Updated: 2/3/2012 Summary This page compares ...
- Git坑点——remote: error: GH007: Your push would publish a private email address.
使用命令:git push -u origin master ,把本地库的内容推送到远程库的过程中,出现了问题 ——remote: error: GH007: Your push would pu ...
- unable to auto-detect email address
git错误:unable to auto-detect email address 2017年11月14日 08:51:08 陈君豪 阅读数:7914 idea 用git更新的时候报错,详细错误信 ...
- git中报unable to auto-detect email address 错误的解决拌办法
昨天刚配置好的git,今天刚要commit一些修改,就遇到了这个问题** Please tell me who you are. Run git config --global user.email ...
- How to Verify Email Address
http://www.ruanyifeng.com/blog/2017/06/smtp-protocol.html 如何验证 Email 地址:SMTP 协议入门教程 https://en.wiki ...
- fatal: unable to auto-detect email address (got 'tim@newton.(none)')的解决方法
问题描述: 使用git commit -m "wrote a readme file",就遇到了这个问题** Please tell me who you are. Run git ...
- git中报unable to auto-detect email address
git commit 时报错: ** Please tell me who you are. Run git config --global user.email "you@example. ...
- fatal: unable to auto-detect email address (got 'CC@LAPTOP-UPQ1N1VQ.(none)')
git 提交问题出现小解决: 在输入 git commit -m "输入的是对这个版本的描述信息" 然后报错:fatal: unable to auto-detect email ...
- How to change default root@ email address linux / postfix / centos?
Change root@hostname to different email address By default, any email sent by system is sent to root ...
随机推荐
- 多线程02.继承Thread类
package chapter2; /** * 1.使用static虽然完成了当前的功能. * 但是static的生命周期比较长,需要在所有线程执行完成后才会结束. * 还有号没有按照顺序进行打印 * ...
- 联盛德 HLK-W806 (五): W801开发板上手报告
目录 联盛德 HLK-W806 (一): Ubuntu20.04下的开发环境配置, 编译和烧录说明 联盛德 HLK-W806 (二): Win10下的开发环境配置, 编译和烧录说明 联盛德 HLK-W ...
- 【原】MDC日志链路设计
背景 我们项目中现有日志系统,采用的是slf4j+logback这套日志组件,也是Java生态里面比较常用的一个日志组件,但是随着分布式的演进,这套组件明显存在以下几个问题: 1.各种无关日志穿行其中 ...
- CF1445E four points
我们不妨枚举四个点的移动方向. 那我们可以直接算出在该情况的最优的答案. #include<iostream> #include<cstdio> #include<alg ...
- 关于 n 个 [0,1] 的随机变量第 k 小的期望值
今天做到一道题,感觉里面一个结论有点意思,就到网上扒了篇证明(bushi)下来了. 知乎回答习惯,先抛结论,再给证明(大雾 结论:对于 \(n\) 个取值范围为 \([0,1]\) 的随机变量 \(x ...
- 【豆科基因组】普通豆/菜豆/四季豆Common bean (Phaseolus vulgaris L.) 683个自然群体重测序2020NG
目录 一.来源 二.结果 683份材料重测序 地方种landraces和育种品系breeding lines的多样性 表型和基因-环境互作(G by E) 菜豆产量潜力相关的MTAs(显著关联位点) ...
- MariaDB——在Linux中查找数据库路径,并进入数据库
1.直接在命令行运营mysql,如果出现下图,说明数据库路径没有设置到环境变量里. 2.找出数据库路径,可以用ps -ef | grep my 命令,查找后台正在执行的命令任务中,包含my字母开头的所 ...
- C语言中的指针的小标可以是负数
首先,创建一个正常的数组 int A[20];.然后用指针指向其中间的元素 int *A2 = &(A[10]); 这样,A2[-10 ... 9] 就是一个可用的有效范围了. 1 2 3 4 ...
- adverb
An adverb is a word or an expression that modifies a verb, adjective, another adverb, determiner [限定 ...
- accelerate
accelerate accelerare, accumulare和accurate共享一个含义为to的词根,后半截分别是:fast, pile up, care (关心则精确). 近/反义词: ex ...