CodeForces - 420A (字符对称问题)
来源:互联网 发布:舞蹈培训网络推广方案 编辑:程序博客网 时间:2024/06/06 02:24
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
AHA
YES
Z
NO
XO
NO
Source
#include <iostream>#include <algorithm>#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>using namespace std;int main(){ char c[100050]; int i,n; while(cin>>c) { int len=strlen(c); int flag=0; for(i=0;i<=len/2;i++) if(c[i]!=c[len-1-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=1; break; } if(flag) cout<<"NO"<<endl; else cout<<"YES"<<endl; } return 0;}
- CodeForces - 420A (字符对称问题)
- codeforces 594A Warrior and Archer [对称博弈]【博弈】
- CodeForces - 426B(对称图形)
- 对称问题/回文问题
- 最长对称字符子串
- 代码实现问题 [CodeForces-893A] [Problem A]
- [oj]樱花对称问题
- 对称举证判断问题
- 对称二叉树问题
- 【发现】空间对称问题
- 二叉树对称问题
- CodeForces-a
- 字符串中出现的对称字符
- 01:判断字符序列是否对称
- 删除部分字符使字符串对称
- Codeforces 903A A
- codeforces 181.div2 300A --Array 思维问题
- 【CodeForces】624A - Save Luke(数学小问题)
- CodeForces - 416A (判断大于小于等于 模拟题)
- 深度学习FPGA实现基础知识15(Matlab图像处理“卷积”运算)
- CodeForces - 417A(思维题)
- CodeForces - 417B (思维题)
- CodeForces - 417E(随机数)
- CodeForces - 420A (字符对称问题)
- php多进程学习
- 辗转相除法的证明
- Codeforces 424A (思维题)
- CodeForces - 424B (贪心算法)
- 算法的重要性
- Codeforces 424C(异或)
- CodeForces - 426A(排序)
- CodeForces - 426B(对称图形)