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 ...
随机推荐
- SpringCloud升级之路2020.0.x版-42.SpringCloudGateway 现有的可供分析的请求日志以及缺陷
本系列代码地址:https://github.com/JoJoTec/spring-cloud-parent 网关由于是所有外部用户请求的入口,记录这些请求中我们需要的元素,对于线上监控以及业务问题定 ...
- Flink 是如何统一批流引擎的
关注公众号:大数据技术派,回复"资料",领取1000G资料. 本文首发于我的个人博客:Flink 是如何统一批流引擎的 2015 年,Flink 的作者就写了 Apache Fli ...
- 如何在 ShardingSphere 中开发自己的 DistSQL
在<DistSQL:像数据库一样使用 Apache ShardingSphere>和<SCTL 涅槃重生:投入 RAL 的怀抱>中,已经为大家介绍了 DistSQL 的设计初衷 ...
- Codeforces 1276D - Tree Elimination(树形 dp)
Codeforces 题面传送门 & 洛谷题面传送门 繁琐的简单树形 dp(大雾),要是现场肯定弃了去做 F 题 做了我一中午,写篇题解纪念下. 提供一种不太一样的思路. 首先碰到这样的题肯定 ...
- python-django-聚合与统计
l例子1: 这里的values_list 相当于SQL语句里面的GROUP BY的功能,但是返回的是一个元组 要实现示例当中的直接用,与数据库格式有关将模型设计得更加完美 模型: 注意related_ ...
- ansible-playbook 安装redis 主从
ansible-playbook 安装redis 主从 手动在测试机上安装一遍redis,最好使用utils下面的install_server.sh安装服务,然后将redis的配置文件和init需要的 ...
- .Net调用Java的实现方法
一. IKVM 1.1下载配置IKVM 1.1.1. 下载路径 http://www.ikvm.net/index.html 1.1.2. 设置路径 解压ikvm-0.42.0.3.zip,并将%IK ...
- Spark(二十)【SparkSQL将CSV导入Kudu】
目录 SparkSql 将CSV导入kudu pom 依赖 scala 代码 启动脚本 SparkSql 将CSV导入kudu pom 依赖 <properties> <spark. ...
- 关于vue-cli中-webkit-flex-direction: column失效问题
我最近在用vue-cli更新项目,在我引入layer.css后会报错并且使用弹性盒时查看元素的时候没有-webkit-flex-direction: column这个属性会失效 这个本身就不打算给di ...
- Shell学习(十)——du、df命令
一.du 命令 1.命令格式: du [选项][文件] 2.命令功能: 显示每个文件和目录的磁盘使用空间. 3.命令参数: -a或-all 显示目录中个别文件的大小. -b或-bytes 显示目录或文 ...