??
题意 给一个字符串 判定其是否为回文串和镜像串 回文串很好判断 镜像串对于每一个字符用数组保存它的镜像字符就行了 没有的就是空格
注意若字符串长度为奇数 中间那个字母必须是对称的才是镜像串
#include
#include
#include
const int N = 35;
int l;
char s[N], mc[] = "A 3 HIL JM O ...
分类:
其他好文 时间:
2014-08-30 10:00:09
阅读次数:
179
http://acm.timus.ru/problem.aspx?space=1&num=1635
给出一个字符串,将这个字符串分成尽量少的回文串。
起初没有思路,想着应该先预处理出所有的回文串,然后进行dp。但是字符串的长度是4000,O(n^3)肯定不行,其实可以转化为O(n^2),就是枚举中点而不是枚举起点和终点,又NC了吧。
然后就是线性的dp了。dp[i]表示到第i...
分类:
其他好文 时间:
2014-08-26 17:31:46
阅读次数:
218
题意 判断一个串最少可以分解为多少个对称串 一个串从左往后和从右往左是一样的 这个串就称为对沉串
令d[i]表示给定串的前i个字母至少可以分解为多少个对称串 那么对于j=1~i 若(i,j)是一个对称串 那么有 d[i]=min(d[i],d[j-1]+1) 然后就得到答案了
#include
#include
#include
using namespace std;...
分类:
其他好文 时间:
2014-08-25 17:11:44
阅读次数:
181
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (i...
分类:
其他好文 时间:
2014-08-22 00:14:05
阅读次数:
172
题目大意:求出区间[a,b]之间的回文质数。 a10000)13 break;14 check[c]=true;15 if (i % prime[j]==0)16 break;17 ...
分类:
其他好文 时间:
2014-08-21 14:34:14
阅读次数:
192
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (i...
分类:
其他好文 时间:
2014-08-19 23:42:35
阅读次数:
227
Description
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, the name "anna" is a palindrome. Numbers can also be palindromes (e.g.
151 or 753357)....
分类:
其他好文 时间:
2014-08-19 12:57:34
阅读次数:
189
本题就是专门肯人的题目,给出的列子也是故意误导人的。
其实就考一点:没有mirror的字母存在的时候就可以判定整个字符串不是mirror!
如下面的mirrored string的叙述:
A mirrored string is a string for which when each of the elements of the string is changed to its rever...
分类:
其他好文 时间:
2014-08-14 16:51:28
阅读次数:
208
Palindromes
A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA" is a palindrome because it is the same when t...
分类:
其他好文 时间:
2014-08-09 21:36:09
阅读次数:
344
/*Palindromes _easy version
Problem Description
“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。请写一个程序判断读入的字符串是否是“回文”。
Input
输入包含多个测试实例,输入数据的第一行是一个正整数n,表示测试实例的个数,后面紧跟着是n个字符串。
Output
如果一个字符串是...
分类:
其他好文 时间:
2014-08-05 14:14:29
阅读次数:
222