hdu 1544 水题
2013-11-07 19:18
357 查看
水题
/* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include <iostream> #include <algorithm> #include <queue> #include <set> #include <map> #include <stack> #include <string> #include <vector> #include <deque> #include <list> #include <functional> #include <numeric> #include <cctype> using namespace std; const int MAX_LEN = 5009; char str[MAX_LEN]; int work() { int len = strlen(str); int ret = 0, j, k; for(int i = 0; i < len; i++) { j = i; while(j >= 0) { k = 2 * i - j; if(k >= len || str[j] != str[k]) { break; } ret++; j--; } } for(int i = 1; i < len; i++) { j = i - 1; if(str[j] != str[i]) { continue; } while(j >= 0) { k = 2 * i - 1 - j; if(k >= len || str[j] != str[k]) { break; } ret++; j--; } } return ret; } int main() { while(scanf("%s", str) == 1) { printf("%d\n", work()); } return 0; }
相关文章推荐
- php应用数据库连接中的单例模式
- 【Android】菜单功能的实现:使用Java代码
- 将java源码打成jar包的两种方法
- WordPress Think Responsive Themes ‘upload_settings_image.php’任意文件上传漏洞
- DELL-linux-风扇
- 有关爬虫的
- 如何设置ubuntu和redhat网络接口
- 长英文自动换行的最终解决方法
- C语言结构体
- C#中 托管资源和非托管资源
- hdu2087
- Linux Kernel ‘write_tag_3_packet()’函数本地基于堆的缓冲区溢出漏洞
- Linux Kernel 整数溢出漏洞
- 网络体系结构(OSI七层模型)介绍
- javascript null与undefined
- Linux Kernel ‘drivers/staging/wlags49_h2/wl_priv.c’本地缓冲区溢出漏洞
- 【iOS开发】---- 表格滚动时隐藏及显示导航条和标签栏
- Velocity模板引擎试用
- java.lang.IllegalStateException: attempt to re-open an already-closed object
- Linux Kernel ‘exitcode_proc_write()’函数本地缓冲区溢出漏洞