暴力。

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; char s[];
int ans,len,sum; void check(int a,int b)
{
if(s[a]!=s[b]) return;
if(a==b) sum=; else sum=;
int left=a-,right=b+;
while(!(left<||right>=len||s[left]!=s[right]))
left--,right++,sum=sum+;
ans=max(ans,sum);
} int main()
{
gets(s);
len=strlen(s); ans=;
for(int i=;i<len;i++) check(i,i),check(i,i+);
printf("%d\n",ans);
return ;
}

PAT (Advanced Level) 1040. Longest Symmetric String (25)的更多相关文章

  1. PTA (Advanced Level) 1040 Longest Symmetric String

    1040 Longest Symmetric String (25 分) Given a string, you are supposed to output the length of the lo ...

  2. 【PAT甲级】1040 Longest Symmetric String (25 分)(cin.getline(s,1007))

    题意: 输入一个包含空格的字符串,输出它的最长回文子串的长度. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/std ...

  3. PAT 甲级 1040 Longest Symmetric String (25 分)(字符串最长对称字串,遍历)

    1040 Longest Symmetric String (25 分)   Given a string, you are supposed to output the length of the ...

  4. 1040. Longest Symmetric String (25)

    题目链接:http://www.patest.cn/contests/pat-a-practise/1040 题目: 1040. Longest Symmetric String (25) 时间限制 ...

  5. 1040 Longest Symmetric String (25分)(dp)

    Given a string, you are supposed to output the length of the longest symmetric sub-string. For examp ...

  6. PAT甲题题解-1040. Longest Symmetric String (25)-求最长回文子串

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789177.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  7. PAT 1040 Longest Symmetric String[dp][难]

    1040 Longest Symmetric String (25)(25 分) Given a string, you are supposed to output the length of th ...

  8. pat1040. Longest Symmetric String (25)

    1040. Longest Symmetric String (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, ...

  9. PAT 甲级 1040 Longest Symmetric String

    https://pintia.cn/problem-sets/994805342720868352/problems/994805446102073344 Given a string, you ar ...

随机推荐

  1. Linq第三讲

    LINQ 1.查询操作符 (1)源起 .net的设计者在IEnumerable<T>等接口基础之上定义了一系列的扩展方法来方便用户操作集合对象,这些扩展方法构成了LINQ的查询操作符 (2 ...

  2. C# WebBrowser函数互相调用

    在使用C#开发winform程序过程中,我们经常会碰到嵌入了一个WebBrowser的浏览器控件.很多时候,我们需要在程序里控制网页的显示方式,或者调用网页当中的某个JS函数,反过来,也有可能网页也需 ...

  3. org.springframework.transaction.CannotCreateTransactionException

    HTTP Status 500 - Request processing failed; nested exception is org.springframework.transaction.Can ...

  4. Hibernate创建SessionFactory实例

    private static SessionFactory sessionFactory = null;  static {  Configuration configuration =new Con ...

  5. sql定期移植数据的存储过程

    create PROCEDURE [dbo].[Pro_ZT_SYS_LogInfo_clear] @dt_end datetime --清理此日期之前的数据 AS BEGIN SET NOCOUNT ...

  6. js中Object.__proto__===Function.prototype

    参考:http://stackoverflow.com/questions/650764/how-does-proto-differ-from-constructor-prototype http:/ ...

  7. js中子页面父页面方法和变量相互调用

    (1)子页面调用父页面的方法或者变量: window.parent.方法()或者变量名window.parent相当于定位到父页面 之后的操作和在父页面中写代码一样写 window.parent.aa ...

  8. About struct in C

    something new: to set value in struct can be in case i cannot view picture.. i write the snippet her ...

  9. LightOJ 1370 Bi-shoe and Phi-shoe(欧拉函数)

    题意:题目给出一个欧拉函数值F(X),让我们求>=这个函数值的最小数N,使得F(N) >= F(X); 分析:这个题目有两种做法.第一种,暴力打出欧拉函数表,然后将它调整成有序的,再建立一 ...

  10. 转:LoadRunner中参数化技术详解

    LoadRunner中参数化技术详解 LoadRunner在录制脚本的时候,只是忠实的记录了所有从客户端发送到服务器的数据,而在进行性能测试的时候,为了更接近真实的模拟现实应用,对于某些信息需要每次提 ...