Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

Submit Status

Description

Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?

The market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In other words, if we write out the name of the company on a piece of paper in a line (horizontally, from left to right) with large English letters, then put this piece of paper in front of the mirror, then the reflection of the name in the mirror should perfectly match the line written on the piece of paper.

There are many suggestions for the company name, so coming up to the mirror with a piece of paper for each name wouldn't be sensible. The founders of the company decided to automatize this process. They asked you to write a program that can, given a word, determine whether the word is a 'mirror' word or not.

Input

The first line contains a non-empty name that needs to be checked. The name contains at most 105 large English letters. The name will be written with the next sans serif font:

Output

Print 'YES' (without the quotes), if the given name matches its mirror reflection. Otherwise, print 'NO' (without the quotes).

Sample Input

Input
AHA
Output
YES
Input
Z
Output
NO
Input
XO
Output
NO

Source

输入一个字符串,如果字符串中的字符对称,比如长度为5的c[0]c[4]一样,c[1]c[3]一样,并且串中所有字符都是中间对称的,输出YES。
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
int main()
{
char c[];
int i,n;
while(cin>>c)
{
int len=strlen(c);
int flag=;
for(i=;i<=len/;i++)
if(c[i]!=c[len--i]||(c[i]!='A'&&c[i]!='H'&&c[i]!='I'&&c[i]!='M'&&c[i]!='O'&&c[i]!='T'&&c[i]!='U'&&c[i]!='V'&&c[i]!='W'&&c[i]!='X'&&c[i]!='Y'))
{
flag=;
break;
}
if(flag)
cout<<"NO"<<endl;
else
cout<<"YES"<<endl; }
return ;
}

CodeForces - 420A (字符对称问题)的更多相关文章

  1. 天梯赛L2-008 最长对称子串 (字符串处理)

    对给定的字符串,本题要求你输出最长对称子串的长度.例如,给定"Is PAT&TAP symmetric?",最长对称子串为"s PAT&TAP s&quo ...

  2. [CodeForces]Educational Round 52

    幸好我没有打这场,我VP的时候在C题就卡死了,我果然还是太菜了. A Vasya and Chocolate 题意:一个巧克力\(c\)元,买\(a\)赠\(b\),一共有\(n\)元,问能买几个巧克 ...

  3. 通过图片对比带给你不一样的KMP算法体验

    KMP 算法,俗称“看毛片”算法,是字符串匹配中的很强大的一个算法,不过,对于初学者来说,要弄懂它确实不易. 笔者认为,KMP 算法之所以难懂,很大一部分原因是很多实现的方法在一些细节的差异.体现在几 ...

  4. KMP算法学习

    kmp算法完成的任务是:给定两个字符串O和f,长度分别为n和m,判断f是否在O中出现,如果出现则返回出现的位置.常规方法是遍历a的每一个位置,然后从该位置开始和b进行匹配,但是这种方法的复杂度是O(n ...

  5. 【经典算法】——KMP,深入讲解next数组的求解

    我们在一个母字符串中查找一个子字符串有很多方法.KMP是一种最常见的改进算法,它可以在匹配过程中失配的情况下,有效地多往后面跳几个字符,加快匹配速度. 当然我们可以看到这个算法针对的是子串有对称属性, ...

  6. KMP算法 --- 深入理解next数组

    在KMP算法中有个数组,叫做前缀数组,也有的叫next数组. 每一个子串有一个固定的next数组,它记录着字符串匹配过程中失配情况下可以向前多跳几个字符. 当然它描述的也是子串的对称程度,程度越高,值 ...

  7. 转载-KMP算法前缀数组优雅实现

    转自:http://www.cnblogs.com/10jschen/archive/2012/08/21/2648451.html 我们在一个母字符串中查找一个子字符串有很多方法.KMP是一种最常见 ...

  8. 算法_Longest Palindromic Substring(寻找最长回文字串)

    题目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum le ...

  9. KMP算法的一次理解

    1. 引言 在一个大的字符串中对一个小的子串进行定位称为字符串的模式匹配,这应该算是字符串中最重要的一个操作之一了.KMP本身不复杂,但网上绝大部分的文章把它讲混乱了.下面,咱们从暴力匹配算法讲起,随 ...

随机推荐

  1. Spring与jsp表达式的产生的问题

    今天遇到一个问题就是Spring标签与jsp表达式的问题 直接上代码 <form:form commandName="book" action="/book_upd ...

  2. POJ2411 Mondriaan's Dream

    Description Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, af ...

  3. jsp学习一

    <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1&q ...

  4. iOS开发的那些坑

    最近重新拿起了iOS的开发,使用OC和Swift混编,碰到了一些比较棘手的问题,在这里记录下来,方便自己以后或他人不再入坑.这篇文章的内容包含: UITableViewCell的真实结构在iOS的环境 ...

  5. HD1847 Good Luck in CET-4 Everybody!(巴什博弈)

    巴什博弈: 一堆物品n个,最多取m个,最少取1个,最后取走的人获胜 分析:只要保证取玩最后剩m+1个,则必定胜利,所以构造m+1,只要n是 m+1的倍数,则先手必败,每次先手取玩,后手可取使得剩下的仍 ...

  6. js的基础学习

    alert() 函数在 JavaScript 中并不常用,但它对于代码测试非常方便. <!DOCTYPE html> <html> <body> <h1> ...

  7. spring事务学习(转账案例)(一)

    一.创建数据库并插入数据 create database spring_transaction; use spring_transaction; create table account( id in ...

  8. CSS3 动画animation

    关键帧 什么是关键帧.一如上面对Flash原理的描述一样,我们知道动画其实由许多静态画面组成,第一个这样的静态画面可以表述为一帧.其中关键帧是在动画过程中体现了物理明显变化的那些帧. 比如之前的例子中 ...

  9. apache LogFormat参数说明

    在apache的配置文件httpd.conf里一般都有类似于LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Refere ...

  10. Web SQL数据库

    Web SQL数据库:它是一个独立的规范,引入了一组使用SQL操作客户端数据库的API. openDatabase方法:这个方法使用现有的数据库或者新建的数据库创建一个数据库对象.如果数据库存在,op ...