Partitioning by Palindromes
来源:互联网 发布:杜兰特身体数据 编辑:程序博客网 时间:2024/05/16 07:46
#include <cstdio>#include <cstring>#include <cstdlib>#include <algorithm>#include <climits>using std::min;const int MAXN(1010);const int INFI((INT_MAX-1) >> 1);char str[MAXN];int table[MAXN];bool is_palindromes(int l, int r){while(l < r){if(str[l] != str[r])return false;++l;--r;}return true;}int main(){int T;scanf("%d", &T);while(T--){scanf("%s", str+1);int len = strlen(str+1);for(int i = 1; i <= len; ++i){table[i] = INFI;for(int j = 0; j < i; ++j)if(is_palindromes(j+1, i))table[i] = min(table[i], table[j]+1);}printf("%d\n", table[len]);}return 0;}
- Partitioning by Palindromes
- Partitioning by Palindromes
- UVa11584-Partitioning by Palindromes
- uva11584 Partitioning by Palindromes
- UVa11584 Partitioning by Palindromes
- Partitioning by Palindromes
- Partitioning by Palindromes uva111584
- uva11584 Partitioning by Palindromes
- Partitioning by Palindromes
- Partitioning by Palindromes UVA
- Partitioning by Palindromes UVA
- UVa11584 Partitioning by Palindromes
- Partitioning by Palindromes UVA
- Partitioning by Palindromes UVA
- Partitioning by Palindromes UVA
- Partitioning by Palindromes UVA
- Uva 11584 - Partitioning by Palindromes
- UVa 11584 - Partitioning by Palindromes
- VC读取文件的文件版本号
- 【Linux Shell】shell命令读书笔记---第四章:通配符扩展
- Android 中的WiFi学习笔记(转载)----WIFI启动 代码流程走读---网络连接流程
- 三层交换机学习--三层表项精确匹配和最长匹配
- Load 和Activate 的区别
- Partitioning by Palindromes
- iPhone开发中经常用到的控件尺寸大集合
- UI设计原则
- CRM的客户数据模型:Siebel Party Data Model (VI)
- JQuery select控件的相关操作
- 二维图像的三角形变形算法
- 11i and R12 Table Count in Different Module
- [[与((
- 快速排序