九度oj 1528 最长回文子串
2024-09-21 04:04:01
原题链接:http://ac.jobdu.com/problem.php?pid=1528
小白书上的做法,不过这个还要简单些。。。
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
using std::max;
const int Max_N = ;
char ret[Max_N];
void solve() {
int i, j, ans = , n = strlen(ret);
for (i = ; i < n; i++) {
for (j = ; i >= j && i + j < n; j++) {
if (ret[i - j] != ret[i + j]) break;
ans = max(ans, j << | );
}
for (j = ; i >= j && i + j + < n; j++) {
if (ret[i - j] != ret[i + j + ]) break;
ans = max(ans, (j << ) + );
}
}
printf("%d\n", ans);
}
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
while (gets(ret)) solve();
return ;
}
最新文章
- Windows Live Writer测试
- 【Ngui 学习系列之一:简单组件的操作】
- 跨过几个坑,终于完成了我的第一个Xamarin Android App!
- Session和Cookie的作用以及实现
- Unity3D热更新全书-脚本(四) 用C#LightEvil搭建实际开发使用的脚本框架
- Scrum Meeting 10-20151216
- 简单翻译和补充:1. GNU ARM Eclipse
- javascript--自己用的插件
- Quartz.net Cron表达式
- [转]laravel 4之视图及Responses
- JSON 数组格式
- Elasticsearch 5.0 安装 Search Guard 5 插件 (五)
- oracle索引
- 爬虫之爬取网贷之家在档P2P平台基本数据并存入数据库
- 回归模型效果评估系列1-QQ图
- [Swift]LeetCode266.回文全排列 $ Palindrome Permutation
- CF809E Surprise me!(莫比乌斯反演+Dp(乱搞?))
- IOS 数据存储之 FMDB 详解
- ";add-apt-repository"; On Linux
- Python&;Appium实现安卓手机图形解锁