A. Jabber ID

2024-08-28 07:18
文章标签 id jabber

本文主要是介绍A. Jabber ID,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

A. Jabber ID
time limit per test
0.5 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Jabber ID on the national Berland service ?Babber? has a form <username>@<hostname>[/resource], where

  • <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters ?_?, the length of<username> is between 1 and 16, inclusive.
  • <hostname> — is a sequence of word separated by periods (characters ?.?), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive.
  • <resource> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters ?_?, the length of<resource> is between 1 and 16, inclusive.

The content of square brackets is optional — it can be present or can be absent.

There are the samples of correct Jabber IDs: mike@codeforces.com007@en.codeforces.com/contest.

Your task is to write program which checks if given string is a correct Jabber ID.

Input

The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.

Output

Print YES or NO.

Sample test(s)
input
mike@codeforces.com
output
YES
input
john.smith@codeforces.ru/contest.icpc/12
output
NO
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long LL;
char s[205];

int dig(char c)
{
if(c>='0'&&c<='9')return 1;
return 0;
}
int let(char c)
{
if(c>='A'&&c<='Z' || c>='a'&&c<='z')return 1;
return 0;
}

int check()
{
int n = strlen(s), p = 0;
while(p<n && s[p]!='@')p++;
if(p==n) return 0;
if(p < 1 || p > 16)return 0;
//puts("==");

for(int i = 0; i < p; i++)
if(s[i]!='_' && !dig(s[i]) && !let(s[i]))return 0;
//puts("===");
int pre = p+1;
while(p<n && s[p]!='/')p++;
if(p-pre<1 || p-pre>32)return 0;

int cnt = 0;
for(int i = pre; i < p; i++)
{
if(s[i]=='.')
{
if(cnt<1 || cnt>16)return 0;
cnt = 0;
}
else
{
if(s[i]!='_' && !dig(s[i]) && !let(s[i]))
return 0;
cnt++;
}
}
if(cnt<1 || cnt>16)return 0;

if(p < n)
{
//puts("--");
cnt = 0;
for(int i = p+1; i < n; i++)
{
if(s[i]=='/')
{
if(cnt<1 || cnt>16)return 0;
cnt = 0;
}
else
{
if(s[i]!='_' && !dig(s[i]) && !let(s[i]))
return 0;
cnt++;
}
}
if(cnt<1 || cnt>16)return 0;
}
return 1;
}
int main()
{
scanf("%s",s);
puts(check()?"YES":"NO");

return 0;
}

这篇关于A. Jabber ID的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1114090

相关文章

Springboot3+将ID转为JSON字符串的详细配置方案

《Springboot3+将ID转为JSON字符串的详细配置方案》:本文主要介绍纯后端实现Long/BigIntegerID转为JSON字符串的详细配置方案,s基于SpringBoot3+和Spr... 目录1. 添加依赖2. 全局 Jackson 配置3. 精准控制(可选)4. OpenAPI (Spri

MySQL查看表的最后一个ID的常见方法

《MySQL查看表的最后一个ID的常见方法》在使用MySQL数据库时,我们经常会遇到需要查看表中最后一个id值的场景,无论是为了调试、数据分析还是其他用途,了解如何快速获取最后一个id都是非常实用的技... 目录背景介绍方法一:使用MAX()函数示例代码解释适用场景方法二:按id降序排序并取第一条示例代码解

使用雪花算法产生id导致前端精度缺失问题解决方案

《使用雪花算法产生id导致前端精度缺失问题解决方案》雪花算法由Twitter提出,设计目的是生成唯一的、递增的ID,下面:本文主要介绍使用雪花算法产生id导致前端精度缺失问题的解决方案,文中通过代... 目录一、问题根源二、解决方案1. 全局配置Jackson序列化规则2. 实体类必须使用Long封装类3.

SpringBoot整合mybatisPlus实现批量插入并获取ID详解

《SpringBoot整合mybatisPlus实现批量插入并获取ID详解》这篇文章主要为大家详细介绍了SpringBoot如何整合mybatisPlus实现批量插入并获取ID,文中的示例代码讲解详细... 目录【1】saveBATch(一万条数据总耗时:2478ms)【2】集合方式foreach(一万条数

mysql数据库重置表主键id的实现

《mysql数据库重置表主键id的实现》在我们的开发过程中,难免在做测试的时候会生成一些杂乱无章的SQL主键数据,本文主要介绍了mysql数据库重置表主键id的实现,具有一定的参考价值,感兴趣的可以了... 目录关键语法演示案例在我们的开发过程中,难免在做测试的时候会生成一些杂乱无章的SQL主键数据,当我们

mysql8.0无备份通过idb文件恢复数据的方法、idb文件修复和tablespace id不一致处理

《mysql8.0无备份通过idb文件恢复数据的方法、idb文件修复和tablespaceid不一致处理》文章描述了公司服务器断电后数据库故障的过程,作者通过查看错误日志、重新初始化数据目录、恢复备... 周末突然接到一位一年多没联系的妹妹打来电话,“刘哥,快来救救我”,我脑海瞬间冒出妙瓦底,电信火苲马扁.

4-4.Andorid Camera 之简化编码模板(获取摄像头 ID、选择最优预览尺寸)

一、Camera 简化思路 在 Camera 的开发中,其实我们通常只关注打开相机、图像预览和关闭相机,其他的步骤我们不应该花费太多的精力 为此,应该提供一个工具类,它有处理相机的一些基本工具方法,包括获取摄像头 ID、选择最优预览尺寸以及打印相机参数信息 二、Camera 工具类 CameraIdResult.java public class CameraIdResult {

集群环境下为雪花算法生成全局唯一机器ID策略

雪花算法是生成数据id非常好的一种方式,机器id是雪花算法不可分割的一部分。但是对于集群应用,让不同的机器自动产生不同的机器id传统做法就是针对每一个机器进行单独配置,但这样做不利于集群水平扩展,且操作过程非常复杂,所以每一个机器在集群环境下是一个头疼的问题。现在借助spring+redis,给出一种策略,支持随意水平扩展,肥肠好用。 大致策略分为4步: 1.对机器ip进行hash,对某一个(大于

在实现回显功能模块的时候,把ID设置成全局变量了

在hsapprove.jsp中: <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><script type="text/javascript">function edittodayhs(hsid){//alert(hsid);//

PL/SQL工具创建Oracle数据库表,实现id字段的自动递增

通过PL/SQL工具,创建Oracle数据库表,如何实现字段ID自动递增; Oracle的自增需要依靠序列和触发器共同实现 比如:先创建一个表 create table test (id int primary key, name varchar2(10)); 创建一个序列 create sequence test_seq increment by 1 start with 1  min