题目地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=6&problem=342&mosmsg=Submission+received+with+ID+12044263

C++代码:

#include <cstdio>
#include <cstring>
int main()
{
char a[3000];
char s[3000];
char str[]={'A','*','*','*','3',
'*','*','H','I','L',
'*','J','M','*','O',
'*','*','*','2','T',
'U','V','W','X','Y',
'5','0','1','S','E','*',
'Z','*','*','8','*'};
while(scanf("%s",a)!=EOF)
{
strcpy(s,a);
int isp=0,ism=0;
int len=strlen(s);
int i,j;
for(i=0,j=len-1;i<=j;++i,--j)
{
if((s[i]=='0'||s[i]=='O')&&(s[j]=='0'||s[j]=='O'))
continue;
else
if(s[i]!=s[j])
break;
}
if(i>j)isp=1;
for(i=0;i<len;++i)
{
if(s[i]>='A'&&s[i]<='Z')
s[i]=str[s[i]-'A'];
else
s[i]=str[s[i]-'0'+26];
}
for(i=0,j=len-1;i<len;++i,--j)
{
if((a[i]=='0'||a[i]=='O')&&(s[j]=='0'||s[j]=='O'))
continue;
else
if(a[i]!=s[j])
break;
}
if(i==len)
ism=1;
if(isp==0&&ism==0)
printf("%s -- is not a palindrome.\n\n",a);
else
if(isp==1&&ism==0)
printf("%s -- is a regular palindrome.\n\n",a);
else
if(isp==0&&ism==1)
printf("%s -- is a mirrored string.\n\n",a);
else
printf("%s -- is a mirrored palindrome.\n\n",a);
}
return 0; }

UVa-Palindromes的更多相关文章

  1. UVA - 11584 Partitioning by Palindromes[序列DP]

    UVA - 11584 Partitioning by Palindromes We say a sequence of char- acters is a palindrome if it is t ...

  2. UVA 11584 一 Partitioning by Palindromes

    Partitioning by Palindromes Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:%lld & %l ...

  3. UVa 353 - Pesky Palindromes

    称号:字符串统计回文子的数量. 分析:dp,暴力.因为数据是小,直接暴力可以解决. 说明:(UVa最终评出800该). #include <iostream> #include <c ...

  4. uva 11584 Partitioning by Palindromes 线性dp

    // uva 11584 Partitioning by Palindromes 线性dp // // 题目意思是将一个字符串划分成尽量少的回文串 // // f[i]表示前i个字符能化成最少的回文串 ...

  5. 区间DP UVA 11584 Partitioning by Palindromes

    题目传送门 /* 题意:给一个字符串,划分成尽量少的回文串 区间DP:状态转移方程:dp[i] = min (dp[i], dp[j-1] + 1); dp[i] 表示前i个字符划分的最少回文串, 如 ...

  6. uva 401.Palindromes

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  7. UVA 11584 Partitioning by Palindromes (字符串区间dp)

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  8. 【UVa】Partitioning by Palindromes(dp)

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=27&page=sh ...

  9. UVa 11584 - Partitioning by Palindromes(线性DP + 预处理)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  10. uva 401 Palindromes 解题报告

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

随机推荐

  1. 前端project师,确定你的目标吧!无能的人才管他叫命运

    导语: 你为自己定过一个不靠谱的目标,是20年前的事了吧. 长大你想干什么?你的回答是什么?现在实现了吗? 如今,你每天都坐在同一个格子间的同一个电脑前,会不会感到每天都像是在复印,感到前途是模糊的, ...

  2. POJ - 1006 Biorhythms 周期相遇 两个思路程序

    Description Some people believe that there are three cycles in a person's life that start the day he ...

  3. ASP.NET - URL中参数加密解密操作

    效果: 代码: using System; using System.Text; using System.IO; using System.Security.Cryptography; public ...

  4. Qt 中文乱码解决大全

    源地址:http://blog.csdn.net/xcy2011sky/article/details/7168376 解决中文乱码,最好知道乱码是什么格式比如说:utf-8. 解决方案: 1.让整个 ...

  5. java按值传递理解(转)

    ava没有引用传递只有按值传递,没有引用传递只有按值传递,值传递. 通过下面代码解释: 1 public class Test { 2 public static void main(String[] ...

  6. eclipse升级后Android使用JAR报错

    升级ADT22以后,老项目编译时后遇到 NoDefFoundClassError  这个错误,因为项目中使用了jar文件. 遇到此问题的解决步骤: 1.项目根目录下建立 libs ,并将jar文件移入 ...

  7. UIGestureRecognizer在多层视图中的触发问题

    在一个superview中,添加了一个subview.tap一下superview,将subview隐藏起来. 在视图superview添加一个UITapGestureRecognizer对象,在UI ...

  8. uva 816 BFS求最短路的经典问题……

    一开始情况没有考虑周全,直接WA掉了, 然后用fgets()出现了WA,给改成scanf就AC了 题目不是很难,用心就好…… #include <iostream> #include &l ...

  9. JavaScript的原型继承

    JavaScript是一门面向对象的语言.在JavaScript中有一句很经典的话,万物皆对象.既然是面向对象的,那就有面向对象的三大特征:封装.继承.多态.这里讲的是JavaScript的继承,其他 ...

  10. golang做的邮件服务器

    https://gowalker.org/github.com/gleez/smtpd https://www.v2ex.com/t/133221