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. Redis队列跟MQ的区别

    Redis队列:Redis队列是一个Key-Value的NoSQL数据库,开发维护很活跃,虽然是一个Key-Value数据库存储系统,但它本身支持MQ功能,所以完全可以当做一个轻量级的队列服务来使用 ...

  2. MYSQL5.8----M4-5

    mysql> CREATE TABLE joson( id INT AUTO_INCREMENT PRIMARY KEY, context JSON NOT NULL)// Query OK, ...

  3. PHP-FPM运行状态的实时查看及监控详解

    https://www.jb51.net/article/97640.htm https://blog.csdn.net/Dr_cokiy/article/details/105580758

  4. 深度探讨 PHP 之性能

    1.缘起 关于PHP,很多人的直观感觉是PHP是一种灵活的脚本语言,库类丰富,使用简单,安全,非常适合WEB开发,但性能低下.PHP的性能是否真的就 如同大家的感觉一样的差呢?本文就是围绕这么一个话题 ...

  5. JuiceFS 数据读写流程详解

    对于文件系统而言,其读写的效率对整体的系统性能有决定性的影响,本文我们将通过介绍 JuiceFS 的读写请求处理流程,让大家对 JuiceFS 的特性有更进一步的了解. 写入流程 JuiceFS 对大 ...

  6. UE4打包启动失败:RunUAT.bat ERROR: AutomationTool failed to compile.

    打包配置正常的情况下,出现下面Log: RunUAT.bat ERROR: AutomationTool failed to compile. 基本上,可以先排查下任务管理器中是不是有UE4Edito ...

  7. Freeswitch 安装爬坑记录1

    2 Freeswitch的安装 2.1 准备工作 服务器安装CentOS 因为是内部环境,可以关闭一些防火墙设置,保证不会因为网络限制而不能连接 关闭防火墙 查看防火墙 systemctl statu ...

  8. 日常Java 2021/9/27

    题目: 在某个比赛中,有6个评委为参赛的选手打分,分数为1-100的随机整数.选手的最后得分为:除去最高分和最低分后的4个评委分值的平均值(不考虑小数部分). package m; import ja ...

  9. 数仓day01

    1. 该项目适用哪些行业? 主营业务在线上进行的一些公司,比如外卖公司,各类app(比如:下厨房,头条,安居客,斗鱼,每日优鲜,淘宝网等等) 这类公司通常要针对用户的线上访问行为.消费行为.业务操作行 ...

  10. 零基础学习java------day18------properties集合,多线程(线程和进程,多线程的实现,线程中的方法,线程的声明周期,线程安全问题,wait/notify.notifyAll,死锁,线程池),

    1.Properties集合 1.1 概述: Properties类表示了一个持久的属性集.Properties可保存在流中或从流中加载.属性列表中每个键及其对应值都是一个字符串 一个属性列表可包含另 ...