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.com, 007@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.

Examples
input
mike@codeforces.com
output
YES
input
john.smith@codeforces.ru/contest.icpc/12
output
NO
直接模拟
#include<stdio.h>
#include<string.h>
bool panduan(char c)
{
if((c!='_')&&(c<'a'||c>'z')&&(c<'A'||c>'Z')&&(c<'0'||c>'9'))return false;
else return true;
}
int main()
{
char s[100+10];
gets(s); int len=strlen(s);
char user[100];
char host[100];
char res[100];
int i,len1,len2,len3;
int ans=1;
//user
for(i=0;i<len;i++)
{
if(s[i]=='@')
{
len1=i;
break;
}
user[i]=s[i];
if(i==len-1&&s[i]!='@')ans=0;
}
if(s[len-1]=='@')
ans=0;
if(ans==1)
{
if(len1<1||len1>16)ans=0;
else
{
for(i=0;i<len1;i++)
{
if(!panduan(user[i]))
{
ans=0;
break;
}
}
}
}
//host
for(i=len1+1;i<len;i++)
{
if(s[i]=='/')
{
len2=i-len1-1;
break;
}
host[i-len1-1]=s[i];
if(i==len-1&&s[i]!='/')
{
len2=len-len1-1;
}
}
if(ans==1)
{
if(len1<1||len1>32)ans=0;
else
{
int sum=0;
for(i=0;i<len2;i++)
{
if(!panduan(host[i]))
{
if(host[i]=='.')
{
if(sum>16||sum<1||(i==len2-1))
{
ans=0;break;
}
sum=0;
}
else ans=0;
}
else sum++;
if(ans==0)
break; }
}
}
//res
if(s[len-1]=='/')
ans=0;
if(len1+len2+2<len&&ans==1)
{
for(i=len1+len2+2;i<len;i++)
res[i-len1-len2-2]=s[i];
len3=len-2-len1-len2;
if(len3<1||len3>16)ans=0;
else{
for(i=0;i<len3;i++)
{
if(!panduan(res[i]))
{
ans=0;
break;
}
}}
} if(ans==1)printf("YES\n");
else printf("NO\n"); return 0;
}

Code Forces 21 A(模拟)的更多相关文章

  1. 思维题--code forces round# 551 div.2

    思维题--code forces round# 551 div.2 题目 D. Serval and Rooted Tree time limit per test 2 seconds memory ...

  2. Code Forces 796C Bank Hacking(贪心)

    Code Forces 796C Bank Hacking 题目大意 给一棵树,有\(n\)个点,\(n-1\)条边,现在让你决策出一个点作为起点,去掉这个点,然后这个点连接的所有点权值+=1,然后再 ...

  3. Code Forces 833 A The Meaningless Game(思维,数学)

    Code Forces 833 A The Meaningless Game 题目大意 有两个人玩游戏,每轮给出一个自然数k,赢得人乘k^2,输得人乘k,给出最后两个人的分数,问两个人能否达到这个分数 ...

  4. code forces 436 C. Bus

    C. Bus time limit per test 2 seconds memory limit per test 256 megabytes input standard input output ...

  5. CODE[VS]-蛇形矩阵-模拟-天梯白银

    题目描述 Description 小明玩一个数字游戏,取个n行n列数字矩阵(其中n为不超过100的奇数),数字的填补方法为:在矩阵中心从1开始以逆时针方向绕行,逐圈扩大,直到n行n列填满数字,请输出该 ...

  6. code forces 439 C. The Intriguing Obsession

    C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input s ...

  7. EZ 2018 04 21 NOIP2018 模拟赛(十) -LoliconAutomaton的退役赛

    难得的一次Unrated,避免了重回1500的尴尬 其实题目都还可以,但只不过所有人T1都炸了,可能是数据的锅(假的) 而且我因为T1SB的把T2弃了,没想到是千年水题 T3莫名爆炸,然后TM的40分 ...

  8. EZ 2018 04 21 NOIP2018 模拟赛(九)

    终于停止了掉Rating的浪潮! 猥琐的链接 这次200分才Rank10,而且很多人并列 庆幸T2最后20分钟发现期望的算法打错了,然后拿到了50pts,250收场 T1 水题*1 这道题不仅做过,而 ...

  9. Code Forces 543A Writing Code

    题目描述 Programmers working on a large project have just received a task to write exactly mm lines of c ...

随机推荐

  1. Atitit. Java script 多重多重catch语句的实现and Javascript js 异常机制

    Atitit. Java script 多重多重catch语句的实现and Javascript js 异常机制 1. 语法错误(ERROR)和运行期错误(Exception) 1 2. 错误类型判断 ...

  2. 04、Quick Start for Windows

    创建一个新工程 1.在 VS 上,选择 File > New > Project.. 2.在新工程窗口,选择  Visual C# > Windows Store > Blan ...

  3. 检查是否是移动端(Mobile)、ipad、iphone、微信、QQ等

    <script type="text/javascript"> //判断访问终端 var browser={ versions:function(){ var u = ...

  4. AIX中查找端口号和进程

    1.由端口号查找进程 维护系统或检查到不明的端口自然要去查一下这个端口是由哪个进程来监听的windows可以用命令netstat -ano来查端口对应的进程的pid. aix却并不能,aix需要使用下 ...

  5. iOS开发 支持https请求以及ssl证书配置(转)

    原文地址:http://blog.5ibc.net/p/100221.html 众所周知,苹果有言,从2017年开始,将屏蔽http的资源,强推https 楼主正好近日将http转为https,给还没 ...

  6. C语言 · 数对

    算法训练 数对   时间限制:1.0s   内存限制:512.0MB      问题描述 编写一个程序,该程序从用户读入一个整数,然后列出所有的数对,每个数对的乘积即为该数. 输入格式:输入只有一行, ...

  7. VB.NET &amp; 策略模式(下机用户类型选择)

    上篇文章讲述了对于下机操作和基本数据设定的时间联系,今天主要就是应用"策略模式"来了解了解对于固定用户,以及暂时用户之间的选择,看学习设计模式的时候自己对于策略模式的理解,我们能够 ...

  8. 利用U盘给Intel NUC安装CentOS

    一,UltraISO(用来制作 U 盘启动) 需要新版9.6 下载地址为:http://www.onlinedown.net/soft/614.htm 软件注册码:王涛 7C81-1689-4046- ...

  9. 求逆元 - HNU 13412 Cookie Counter

    Cookie Counter Problem's Link: http://acm.hnu.cn/online/?action=problem&type=show&id=13412&a ...

  10. IOS 中微信 网页授权报 key[也就是code]失效 解决办法

    枪魂微信平台ios手机点击返回 网页授权失败,报key失效.已经解决,原因是授权key只能使用一次,再次使用就会失效. 解决办法:第一次从菜单中进行授权时,用session记录key和open_id. ...