s-palindrome
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".
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
oXoxoXo
TAK
bod
TAK
ER
NIE
分析:考眼力题;
代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <ext/rope>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define vi vector<int>
#define pii pair<int,int>
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
const int maxn=7e5+;
const int mod=1e6+;
const int dis[][]={{,},{-,},{,-},{,}};
using namespace std;
using namespace __gnu_cxx;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=;while(q){if(q&)f=f*p%mod;p=p*p%mod;q>>=;}return f;}
int n,m,cnt,ok;
map<char,int>a;
string b;
bool check(char p,char q)
{
if(p>q)swap(p,q);
if(p=='b'&&q=='d')return true;
if(p=='p'&&q=='q')return true;
return false;
}
int main()
{
int i,j,k,t;
cin>>b;
a['A']=,a['H']=,a['I']=,a['M']=,a['M']=,a['O']=,a['o']=,a['T']=,a['U']=,a['V']=,a['v']=,a['W']=,a['w']=,a['X']=,a['x']=,a['Y']=;
int len=b.length();
rep(i,,len/)if((!a[b[i]]||b[i]!=b[len--i])&&!check(b[i],b[len--i]))return *puts("NIE");
puts("TAK");
//system ("pause");
return ;
}
s-palindrome的更多相关文章
- PALIN - The Next Palindrome 对称的数
A positive integer is called a palindrome if its representation in the decimal system is the same wh ...
- [LeetCode] Longest Palindrome 最长回文串
Given a string which consists of lowercase or uppercase letters, find the length of the longest pali ...
- [LeetCode] Palindrome Pairs 回文对
Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list, so that t ...
- [LeetCode] Palindrome Permutation II 回文全排列之二
Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...
- [LeetCode] Palindrome Permutation 回文全排列
Given a string, determine if a permutation of the string could form a palindrome. For example," ...
- [LeetCode] Palindrome Linked List 回文链表
Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time ...
- [LeetCode] Shortest Palindrome 最短回文串
Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. ...
- [LeetCode] Palindrome Partitioning II 拆分回文串之二
Given a string s, partition s such that every substring of the partition is a palindrome. Return the ...
- [LeetCode] Palindrome Partitioning 拆分回文串
Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...
- [LeetCode] Valid Palindrome 验证回文字符串
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
随机推荐
- js实现url链接encode加密
function urlencode(clearString) { var output = ''; var x = 0; clearString = utf16to8(clearString.toS ...
- VC++中使用ADO方式操作ACCESS数据库
ADO(ActiveX Data Object)是Microsoft数据库应用程序开发的新接口,是建立在OLE DB之上的高层数据库访问技术,即使你对OLE DB,COM不了解也能轻松对付ADO,因为 ...
- $.getjson方法配合在url上传递jsoncallback=?参数,实现跨域获取指定网站某商品访问量
across.php文件在域名www.cms.com程序中 <html><body><div id="pv">99</div>< ...
- Bank Interest
Bank Interest Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) Tota ...
- 解决ORA-00904: invalid identifier标识符无效
方法/步骤 1 大部分情况下,此错误是由于引用了不存在的列名导致的.比如select name from Studtent 当studeng表中无name列时,系统就会报此错误. 2 解决思路是,确定 ...
- Fragment和Activity之间通过广播的方式传递数据
四大组件之间传递数据可以用广播,但是有次面试官说太重了,用eventbus代替.下面的广播传递数据方法仅当学习参考. 1.管理类 /** * 广播管理类:注册广播.注销广播.发送广播 * @autho ...
- apache启动报错:Cannot load php5apache2_2.dll into server
错误信息: httpd.exe: Syntax error on line 178 of D:/Program Files/httpd-2.4.20-x64-vc14-r2 /Apache24/con ...
- ubuntu setup adb tool
sudo add-apt-repository ppa:nilarimogard/webupd8sudo apt-get updatesudo apt-get install android-tool ...
- 介绍XXTEA加密算法及其C实现
介绍XXTEA加密算法及其C实现 http://en.wikipedia.org/wiki/XXTEA “微型加密算法(TEA)及其相关变种(XTEA,Block TEA,XXTEA)都是分组加密算法 ...
- auto_ash
#!/usr/bin/ksh ##############paramter######################startdate=$1' 00:00:01'enddate=$2' 23:59: ...