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 题解的更多相关文章

  1. 转载:邮箱正则表达式Comparing E-mail Address Validating Regular Expressions

    Comparing E-mail Address Validating Regular Expressions Updated: 2/3/2012 Summary This page compares ...

  2. Git坑点——remote: error: GH007: Your push would publish a private email address.

    使用命令:git push -u origin master   ,把本地库的内容推送到远程库的过程中,出现了问题 ——remote: error: GH007: Your push would pu ...

  3. unable to auto-detect email address

    git错误:unable to auto-detect email address 2017年11月14日 08:51:08 陈君豪 阅读数:7914   idea 用git更新的时候报错,详细错误信 ...

  4. git中报unable to auto-detect email address 错误的解决拌办法

    昨天刚配置好的git,今天刚要commit一些修改,就遇到了这个问题** Please tell me who you are. Run git config --global user.email ...

  5. How to Verify Email Address

    http://www.ruanyifeng.com/blog/2017/06/smtp-protocol.html  如何验证 Email 地址:SMTP 协议入门教程 https://en.wiki ...

  6. 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 ...

  7. git中报unable to auto-detect email address

    git commit 时报错: ** Please tell me who you are. Run git config --global user.email "you@example. ...

  8. fatal: unable to auto-detect email address (got 'CC@LAPTOP-UPQ1N1VQ.(none)')

    git 提交问题出现小解决: 在输入 git commit -m "输入的是对这个版本的描述信息" 然后报错:fatal: unable to auto-detect email ...

  9. 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 ...

随机推荐

  1. [Net 6 AspNetCore Bug] 解决返回IAsyncEnumerable<T>类型时抛出的OperationCanceledException会被AspNetCore 框架吞掉的Bug

    记录一个我认为是Net6 Aspnetcore 框架的一个Bug Bug描述 在 Net6 的apsnecore项目中, 如果我们(满足以下所有条件) api的返回类型是IAsyncEnumerabl ...

  2. Redis、Zookeeper实现分布式锁——原理与实践

    Redis与分布式锁的问题已经是老生常谈了,本文尝试总结一些Redis.Zookeeper实现分布式锁的常用方案,并提供一些比较好的实践思路(基于Java).不足之处,欢迎探讨. Redis分布式锁 ...

  3. 阿里性能专家全方位对比Jmeter和Locust,到底谁更香?

    近些年,随着互联网行业的不断发展,用户规模也有了爆发性的增长.产品的性能成为影响用户体验的重要因素.因此,性能测试越来越受到大型互联网企业的重视. 在做性能测试时,通常都会借助一些压测工具来模拟大量的 ...

  4. Pollard-Rho 算法

    Pollard-Rho 一种复杂度大概在 $ O(n^{\frac 1 4} \log n) $ 的分解质因数方法. Miller-Rabin 给定一个 $ 10^{18} $ 范围的数,判断质数 由 ...

  5. 洛谷 P6914 - [ICPC2015 WF]Tours(割边+找性质)

    洛谷题面传送门 神仙题. 深夜写题解感受真好 我们考虑两个简单环 \(C_1,C_2\)​​​,我们假设颜色种类数为 \(k\)​​​,那么我们需要有 \(C_1,C_2\)​​​ 均符合条件,而由于 ...

  6. 【GS文献】全基因组选择模型研究进展及展望

    目录 1. GS概况 2. GS模型 1)直接法 GBLUP 直接法的模型改进 ①单随机效应 ②多随机效应 2)间接法 间接法模型 基于间接法的模型改进 3. GS模型比较 模型比较结论 4.问题及展 ...

  7. ggplot 画堆叠柱状图

    1. 关注下方公众号可获得更多精彩

  8. R2CNN模型——用于文本目标检测的模型

    引言 R2CNN全称Rotational Region CNN,是一个针对斜框文本检测的CNN模型,原型是Faster R-CNN,paper中的模型主要针对文本检测,调整后也可用于航拍图像的检测中去 ...

  9. 《手把手教你》系列技巧篇(四十七)-java+ selenium自动化测试-判断元素是否显示(详解教程)

    1.简介 webdriver有三种判断元素状态的方法,分别是isEnabled,isSelected 和 isDisplayed,其中isSelected在前面的内容中已经简单的介绍了,isSelec ...

  10. 学习java 7.24

    学习内容: Swing编程 由于Swing的所有组件完全采用Java 实现,不再调用本地平台的GUl,所以导致Swing图形界面的显示速度要比AWT图形界面的显示速度慢一些,但相对于快速发展的硬件设施 ...