题意:给一个数n,让你找出长度为偶数,并且是第 n 个回文数. 析:你多写几个就知道了,其实就是 n,然后再加上n的逆序,不过n有点大,直接用string 好了. 代码如下: #include <iostream> #include <cmath> #include <cstdlib> #include <set> #include <cstdio> #include <cstring> #include <algorithm&…
题目链接: B. Lovely Palindromes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or ba…
B. Lovely Palindromes 题目连接: http://www.codeforces.com/contest/688/problem/B Description Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palin…
http://codeforces.com/contest/465/problem/C 给定n和m,以及一个字符串s,s不存在长度大于2的回文子串,如今要求输出一个字典比s大的字符串,且串中字母在一定范围内,而且说相同不存在长度大于2的回文子串. 直接去递归构造就可以.从最后一位開始.每次仅仅要推断是否子串中含有回文串,事实上细致想想仅仅要考虑是否存在一个字符和前两个字符中的一个同样就可以.不卡时限,裸的推断都能过 #include <cstdio> #include <cstdlib&…
Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Halloween computer game. The game is played on a rectangular graveyard with a rectangular chapel in it. During the game, the player places new rectangul…
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2744 题目描述: 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…
请判断一个链表是否为回文链表. 示例 1: 输入: 1->2 输出: false 示例 2: 输入: 1->2->2->1 输出: true 进阶: 你能否用 O(n) 时间复杂度和 O(1) 空间复杂度解决此题? # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def r…
http://codeforces.com/contest/1064/problem/C 题意:给出一个字符串,要求重新排列这个字符串,是他的回文子串数量最多并输出这个字符串. 题解:字典序排列的字符串回文子串最多. #include<bits/stdc++.h> using namespace std; ]; int main() { int n; while(~scanf("%d",&n)) { scanf("%s",s); sort(s,s…
Hrdv is interested in a string,especially the palindrome string.So he wants some palindrome string.A sequence of characters is a palindrome if it is the same written forwards and backwards. For example, 'abeba' is a palindrome, but 'abcd' is not.A pa…
题目大意:输入一个由小写字母组成的字符串,你的任务是把它划分成尽量少的回文串.比如racecar本身就是回文串:fastcar只能分成7个单字母的回文串:aaadbccb最少可分成3个回文串:aaa.d.bccb.字符串的长度不超过1000. 分析:令dp[i]表示从第1个到第 i 个字符所组成的最少回文串数. 我们考虑如果前k个字符构成了1个回文,那么前k+1个字符最多构成2个回文,如果这些字符都相同,那么也只是1个回文串.所以如果第 j 个字母到第 i 个字母能构成回文,那么dp[i] =…