Codeforces - Educational Codeforces Round 14B - s-palindrome(模拟)
2016-07-21 09:06
369 查看
B. s-palindrome
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but
the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.
English alphabet
You are given a string s. Check if the string is "s-palindrome".
Input
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Output
Print "TAK" if the string
s is "s-palindrome" and "NIE" otherwise.
Examples
Input
Output
Input
Output
Input
Output
题意:给出一个字符串,判断是否对称并为纯镜面对称
模拟呗,做的还是挺开心的,每次做模拟都很开心233333我这是什么神奇倾向
先找出纯镜面对称的所有字母和字母对,u和m不对称,略懵逼,仔细研究了一下确实不对称23333
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but
the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.
English alphabet
You are given a string s. Check if the string is "s-palindrome".
Input
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Output
Print "TAK" if the string
s is "s-palindrome" and "NIE" otherwise.
Examples
Input
oXoxoXo
Output
TAK
Input
bod
Output
TAK
Input
ER
Output
NIE
题意:给出一个字符串,判断是否对称并为纯镜面对称
模拟呗,做的还是挺开心的,每次做模拟都很开心233333我这是什么神奇倾向
先找出纯镜面对称的所有字母和字母对,u和m不对称,略懵逼,仔细研究了一下确实不对称23333
#include <stdio.h> #include <math.h> #include <string.h> #include <algorithm> #include <queue> #include <iostream> #include <assert.h> #define INF 0x3f3f3f3f using namespace std; int main() { char s[1005]; while (scanf("%s", s) != EOF) { int flag = 0; for(int i = 0, j = strlen(s) - 1; i < strlen(s) / 2 + 1; i++, j--) { flag = 0; char aa = s[i]; char bb = s[j]; switch(aa) { case 'A': case 'H': case 'I': case 'M': case 'O': case 'o': case 'T': case 'U': case 'V': case 'v': case 'W': case 'w': case 'X': case 'x': case 'Y': flag = 1; break; case 'b': flag = 2; break; case 'p': flag = 3; break; case 'd': flag = 4; break; case 'q': flag = 5; break; } if(flag == 1 && aa == bb) continue; if(flag == 2 && bb == 'd') continue; if(flag == 3 && bb == 'q') continue; if(flag == 4 && bb == 'b') continue; if(flag == 5 && bb == 'p') continue; if(strlen(s) % 2 && i == strlen(s) / 2 + 1 && flag != 1) flag = 6; flag = 6; break; } if(flag != 6) printf("TAK\n"); else printf("NIE\n"); } return 0; }
相关文章推荐
- Android 如何让EditText不自动获取焦点
- 简单背包问题——百炼01:Charm Bracelet
- Android
- Java内容回顾
- JAVA SE 面向对象笔记
- POJ 2366 Sacrament of the sum
- HDU 5723 Abandoned country
- 【linux c】指针与数组的区别_学习笔记_012
- String.format("%1$02d",var)其中%1$0nd是啥意思
- OpenGL ES像素着色器
- 【代码笔记】iOS-正在加载
- LINK : fatal error LNK1104: 无法打开文件“LIBCD.lib”
- Android获取系统信息工具类
- 深入理解Java反射
- 【代码笔记】iOS-正在加载
- struts2类型转换器
- Git之(五)远程管理
- system()
- Git之(五)远程管理
- 2016.7.20 随记