博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1354. Palindrome. Again Palindrome
阅读量:7239 次
发布时间:2019-06-29

本文共 1610 字,大约阅读时间需要 5 分钟。

1354. Palindrome. Again Palindrome

Time limit: 1.0 second Memory limit: 64 MB
A
 
word
 is the nonempty sequence of symbols
 
a
1
a
2
an. A
 
palindrome
 is the word
 
a
1
a
2
an
 that is read from the left to the right and from the right to the left the same way (
a
1
a
2
an
 =
 
ana
n−1
a
1). If
 
S
1
 =
 
a
1
a
2
an
 and
 
S
2
 =
 
b
1
b
2
bm, then
 
S
1
S
2
 =
 
a
1
a
2
an
b
1
b
2
bm. The input contains some word
 
S
1. You are to find a nonempty word
 
S
2
 of the minimal length that
 
S
1
S
2
 is a palindrome.

Input

The first input line contains
 
S
1
 (it may consist only of the Latin letters). It’s guaranteed that the length of
 
S
1
 doesn’t exceed 10000 symbols.

Output

S
1
S
2.

Samples

input output
No
NoN
OnLine
OnLineniLnO
AbabaAab
AbabaAababA
Problem Author: Denis Nazarov
Problem Source: USU Junior Championship March'2005
***************************************************************************************
kmp没想出来,用简单法做的
***************************************************************************************
1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 using namespace std;11 char str[10011];12 int n,i,j,k;13 bool judge(int x)//检查后缀的最大回文14 {15 int h,g;16 for(h=x,g=n-1;g>h;h++,g--)17 if(str[h]!=str[g])18 return false;19 return true;20 }21 int main()22 {23 scanf("%s",str);24 n=strlen(str);25 for(i=0;i
=0;j--)31 cout<
View Code

 

转载于:https://www.cnblogs.com/sdau--codeants/p/3275087.html

你可能感兴趣的文章
Sequence operation(线段树区间多种操作)
查看>>
怎样解决Ubuntu发热严重地问题
查看>>
申请付费苹果开发者账号 注意事项及流程 (转)
查看>>
ThinkPHP 3.2.3 数据缓存与静态缓存
查看>>
2-7-集合运算(A-B)∪(B-A)-线性表-第2章-《数据结构》课本源码-严蔚敏吴伟民版
查看>>
Linux中设置服务自启动的三种方式
查看>>
友盟新功能介绍:在线参数-备用
查看>>
RAC object remastering ( Dynamic remastering )
查看>>
Log4net使用(一)
查看>>
[Android][Android Studio] *.jar 与 *.aar 的生成与*.aar导入项目方法
查看>>
PopUpWindow使用详解(二)——进阶及答疑
查看>>
史上最完整的Android开发工具集合
查看>>
Pythonn new-style class and old-style class
查看>>
Java中对象构造
查看>>
Linq一对多联合查询
查看>>
CYQ.Data 从入门到放弃ORM系列:开篇:自动化框架编程思维
查看>>
在设计DJANGO用户更改密码时,出现NoReverseMatch at /account/password-change/这种妖精如何办?...
查看>>
android中保存一个ArrayList到SharedPreferences的方法
查看>>
NOIP模拟赛20161016R1
查看>>
SQL Server 常用命令
查看>>