题目地址: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. Swift - 判端网络连接状态,连接类型(3G还是Wifi)

    IJReachability是一个使用Swift写的第三方网络检测类.可以测试网络是否连接,并支持3G和Wifi的检测. 使用样例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...

  2. 实战ajax

    原文:实战ajax 实战ajax Ajax的原理简单来说通过XmlHttpRequest对象来向服务器发异步请求,从服务器获得数据,然后用javascript来操作DOM而更新页面. 大家都知道aja ...

  3. 5.单行函数,多行函数,字符函数,数字函数,日期函数,数据类型转换,数字和字符串转换,通用函数(case和decode)

     1  多行函数(理解:有多个输入,但仅仅输出1个结果) SQL>select count(*) from emp; COUNT(*) ------------- 14 B 字符函数Lowe ...

  4. 论文阅读笔记 - Mesos: A Platform for Fine-Grained ResourceSharing in the Data Center

    作者:刘旭晖 Raymond 转载请注明出处 Email:colorant at 163.com BLOG:http://blog.csdn.net/colorant/ 更多论文阅读笔记 http:/ ...

  5. Flash Builder 条件编译的实现

    最近项目需要开发多个版本,  而Flash又没有像C++ 那样的 #ifdef,  来让一套代码支持多个版本的编译发布; 经过研究, 终于知道Flash Builder如何支持条件编译: 1. 在项目 ...

  6. ios23- 文件下载(同步和异步)

    1.第一步:创建一个单例视图 #import <UIKit/UIKit.h> @interface ios23_downViewController : UIViewController& ...

  7. 攻略三战的完美体验3Castle Fantisia阿兰·梅希亚战争艾伦西战记它包含重做版本(这是新的艾伦·梅希亚大战)

    (城堡幻想曲3,纠正大家个错误哦,不是圣魔大战3,圣魔大战是城堡幻想曲2,圣魔大战不是个系列,艾伦西亚战记==艾伦希亚战记,一个游戏日文名:タイトル キャッスルファンタジア -エレンシア戦記-リニュー ...

  8. 导航条——flash导航条

    1.概述 在一些个性网站中,网站导航的首选就是flash导航条,flash导航条可以给浏览者带来更好的视觉效果,是网站个性的主要体现之一. 2.技术要点 主要应用Flash动作脚本中的Button类的 ...

  9. 与众不同 windows phone (4) - Launcher(启动器)

    原文:与众不同 windows phone (4) - Launcher(启动器) [索引页][源码下载] 与众不同 windows phone (4) - Launcher(启动器) 作者:weba ...

  10. 14.2.5.7 Physical Row Structure 物理数据结构:

    14.2.5.7 Physical Row Structure 物理数据结构: InnoDB物理记录结构依赖行格式 在表创建的时候, 默认, InnoDB 使用Antelope 文件存储格式和它的压缩 ...