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. 【Android】15.4 例15-2--Notification基本用法

    分类:C#.Android.VS2015: 创建日期:2016-02-29 一.简介 上一节介绍了通知(Notification)相关的基本内容.这一节先用一个简单示例演示创建和发布本地通知的基本用法 ...

  2. sensor dma alloc failed问题

    打印信息 [CAPTURE][printCapCapbility:93]:D/ driver:sunxi-vfe [CAPTURE][printCapCapbility:94]:D/ card:sun ...

  3. 0077 web.xml中配置Spring MVC时,Servlet-name上报Servlet should have a mapping的错误

    这次是手工建立的web工程目录,在配置webapp/WEB-INF/web.xml的Spring MVC的DispatcherServlet时,在servlet-name上报错:Servlet sho ...

  4. 延时NSTimer

    import Foundationimport UIKit class YijfkController:UIViewController{ override func viewDidLoad() { ...

  5. 基于html5制作3D拳击游戏源码下载

    今天给大家分享一款基于HTML5实现的3d拳王游戏源码.这款实例适用浏览器:360.FireFox.Chrome.Safari.Opera.傲游.搜狗.世界之窗. 不支持IE8及以下浏览器. 在线预览 ...

  6. 超赞的lua开发工具zerobrane

    zerobrane是用lua和wxWidgets编写的ide,而且是跨平台的,支持多种lua解释器,包括love2d. 而且最赞的是支持即时编程,可以在运行时直接修改变量,直接看到结果,不用重新运行, ...

  7. Excel 自定义关闭按钮

    遇到过这样一个需求,是在excel关闭的时候,不要excel本身的保存窗口,只用自定义的. 这个的需要第一,是点击关闭时候触发, 第二:触发后,不能还是弹出那个窗口 第三:取消后,要能停止程序 为了弄 ...

  8. 进一步优化SPA的首屏打开速度(模块化与懒载入) by 嗡

    前言 单页应用的优点在于一次载入全部页面资源,利用本地计算能力渲染页面.提高页面切换速度与用户体验.但缺点在于全部页面资源将被一次性下载完,此时封装出来的静态资源包体积较大,使得第一次打开SPA页面时 ...

  9. 示例 - 如何在Console应用程序中应用SpiderStudio生成的DLL?

    以前面生成的XML/JSON互转DLL为例, 我们写一个Console Appliction来做这件事情, 步骤如下: 1. 创建Console Project 2. 引入www.utilities_ ...

  10. 框架Iframe的退出,IE 火狐都没问题 到360就不跳转页面 刷新一遍才跳转到登录页

    遇到这种情况 ,郁闷死了,来回折腾好几种跳转方法,最后有一个灵感,当我点击退出按钮的时候,我是用jquery $("#ID").click(function(){}) 这种方法异步 ...