CodeForces - 420A (字符对称问题)
2016-05-24 10:16
387 查看
Start Up
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
Output
Input
Output
Input
Output
Source
Coder-Strike 2014 - Finals (online edition, Div. 1)
输入一个字符串,如果字符串中的字符对称,比如长度为5的c[0]c[4]一样,c[1]c[3]一样,并且串中所有字符都是中间对称的,输出YES。
Time Limit: 1000MS | Memory Limit: 262144KB | 64bit IO Format: %I64d & %I64u |
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
Coder-Strike 2014 - Finals (online edition, Div. 1)
输入一个字符串,如果字符串中的字符对称,比如长度为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[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; }
相关文章推荐
- 以前在网络相关的公司学到的,记录一下,http协议和https协议的区别
- CodeForces - 417E(随机数)
- CodeForces - 417B (思维题)
- CodeForces - 417A(思维题)
- 属性访问函数
- CodeForces - 416A (判断大于小于等于 模拟题)
- 使用Redis保存Spring session(基于XML配置文件)
- session 、cookie、token的区别
- CodeForces - 407A
- CodeForces - 407B
- 模式识别(Pattern Recognition)学习笔记(十二)--SVM(广义):大间隔
- 83-Add Binary
- awk入门
- linux生成指定大小的文件
- 后台给GridView绑定数据时给每一行添加一个JS方法
- 网格弹簧质点系统模拟(Spring-Mass System by Fast Method)附源码
- CodeForces - 405C
- GridView相关问题解决
- CodeForces - 405A
- CodeForces - 404B(模拟题)