题目:String to Palindrome
题目大意:给出一字符串,给你三种操作:可以将任何位置的字符删除,可以将任何位置的字符替换,可以在任何位置插入一个字符。问最少的操作能够把这个字符转换成回文。
解题思路:dp【i】【j】代表使字符串i到j位的子串变成回文的最少的操作。替换和删除还算好做,一开始一点都不知道插入该怎么办,后来看了别人的题解发现删除和插入是一样的效果。例...
分类:
其他好文 时间:
2014-08-02 12:58:23
阅读次数:
161
题目:uva10453 - Make Palindrome(递推+ 路径输出)
题目大意:给出一字符串,仅仅只能做增加字符的操作,问最少增加多少字符串可以是的最后的字符串变成回文。并且将这样的字符串(增加长度要是最小的)的任意一种输出。
解题思路:dp【i】【j】代表第i个字符到第j个字符之间要增加的最少的字符串。递推公式:s【i】 == s【j】, dp【i】【j】 = dp...
分类:
其他好文 时间:
2014-08-02 12:56:43
阅读次数:
275
题目:uva10617 - Again Palindrome(记忆化搜索)
题目大意:给出一个字符串,给定删除的操作,能够删除任意位置的字符,问通过这样的操作能够得到的最多的回文。
解题思路:dp【i】【j】代表第i个字符到第j个字符通过删除操作可以得到的最多的回文数目。
如果s【i】 == s【j】 ,那么dp【i】【j】 = dp【i】...
分类:
其他好文 时间:
2014-08-02 12:54:03
阅读次数:
182
注意只有高位放了1之后才能开始统计#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace ...
分类:
其他好文 时间:
2014-08-02 12:42:53
阅读次数:
200
题目:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each ....
分类:
编程语言 时间:
2014-08-02 01:48:12
阅读次数:
246
问题描述:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->...
分类:
其他好文 时间:
2014-08-02 01:33:12
阅读次数:
249
#include using namespace std;int a[1000];int f(int n){ int k=0; while(n) { a[k++]=n%2; n/=2; } return k;}int main(int argc, char *argv[]){ int n,m,...
分类:
其他好文 时间:
2014-08-01 22:45:22
阅读次数:
248
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example, "A man, a plan, a canal: Pan...
分类:
其他好文 时间:
2014-08-01 22:31:42
阅读次数:
208
斐波那契数列。。。利用斐波那契数列的循环:因为结果%n,所以最多有n^2个数后会出现循环。预处理,不能直接用f[maxn][maxn^2]来保存,数组太大。。。所以用vector来保存斐波那契数列%n 的值。 1 #include 2 #include 3 #include 4 #includ...
分类:
其他好文 时间:
2014-08-01 19:04:12
阅读次数:
173
Problem Description:
Given two numbers represented as strings, return multiplication of the numbers as a string.
Note: The numbers can be arbitrarily large and are non-negative.
分析:两个string相乘...
分类:
其他好文 时间:
2014-08-01 16:06:01
阅读次数:
141