hdu5371 Hotaru's problem】的更多相关文章

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2189    Accepted Submission(s): 774 Problem Description Hotaru Ichijou recently is addicated to math problems. Now she is playing with N-sequence…
Hotaru's problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2274    Accepted Submission(s): 795 Problem Description Hotaru Ichijou recently is addicated to math problems. Now she is playin…
[HDOJ 5371] Hotaru's problem Manacher算法+穷举/set Manacher算法一好文:http://blog.csdn.net/yzl_rex/article/details/7908259 套一个Manacher算出回文半径数组p之后 有两种方法 穷举法: 枚举-1的点(依据题意仅仅必为偶数回文) 找在该点回文半径内与其相隔最远 而且回文半径等于他俩距离(即两点为中心的回文串同样) 的点 记录找到时的距离 不断枚举找最大值即为最大回文串长 串长/2*3即为答…
题目链接: http://acm.hdu.edu.cn/showproblem.php? pid=5371 题意: 给出一个长度为n的串,要求找出一条最长连续子串.这个子串要满足:1:能够平均分成三段,2:第一段和第三段相等,3:第一段和第二段回文.求最大子串的长度. 代码: #include<stdio.h> #include<iostream> #include<math.h> #include<stdlib.h> #include<ctype.h…
manacher算法详见 http://blog.csdn.net/u014664226/article/details/47428293 题意:给一个序列,让求其最大子序列,这个子序列由三段组成,第一段和第二段对称,第一段和第三段一样. 思路:首先利用Manacher算法求出以随意两个相邻元素为中心的回文串长度,用a[i]表示i-1,i为中心的回文串长度的一半, 那么问题就转化成了求最大的x,使得a[i]>=x,a[i+x]>=x,这一步能够贪心来做. 将a[i]从大到小排序(间接排序保留…
题目地址:HDU 5371 题意:给你一个具有n个元素的整数序列,问你是否存在这样一个子序列.该子序列分为三部分,第一部分与第三部分同样,第一部分与第二部分对称.假设存在求最长的符合这样的条件的序列. 思路:用Manacher算法来处理回文串的长度,记录下以每个-1(Manacher算法的插入)为中心的最大回文串的长度. 然后从最大的開始穷举,仅仅要p[i]-1即能得出以数字为中心的最大回文串的长度,然后找到右边相应的'-1'.推断p[i]是不是大于所穷举的长度,假设当前的满足三段,那么就跳出,…
pid=5371">HDU 5371 题意: 定义一个序列为N序列:这个序列按分作三部分,第一部分与第三部分同样,第一部分与第二部分对称. 如今给你一个长为n(n<10^5)的序列,求出该序列中N序列的最大长度. 思路: 来自官方题解:修正了一些题解错别字(误 先用求回文串的Manacher算法.求出以第i个点为中心的回文串长度.记录到数组p中 要满足题目所要求的内容.须要使得两个相邻的回文串,共享中间的一部分,也就是说.左边的回文串长度的一半,要大于等于共享部分的长度,右边回文串也…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5371 题意:把一个数字串A翻过来(abc翻过来为cba)的操作为-A,我们称A-AA这样的串为N-sequence,现在给你一个数字串,问你这个串中最长的N-sequence子串长度 解:可以想到A-A是一个回文串,-AA也是一个回文串,那么首先Manacher跑一遍求出所有回文子串 可以想到任意两个互相覆盖串中心点的回文子串都可以表示成N-sequence 然后大概有三种搞法: 1.时间复杂度O(…
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/转载请注明出处,侵权必究,保留最终解释权!   Problem Description Hotaru Ichijou recently is addicated to math problems. Now she is playing with N-sequence.Let's define N-s…
Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2189    Accepted Submission(s): 774 Problem Description Hotaru Ichijou recently is addicated to math problems. Now she is playing with N-sequence…
题意:在一个字符串里面找最长的[A][B][A]子串,其中[A][B]是回文串,[A]和[B]的长度相等 思路:[A][B]是回文串,所以[B][A]也是回文串.先预处理出每个点的最大回文半径Ri,枚举[A][B]的对称轴位置p,那么就是要找最大的一个[B][A]的对称轴位置i,满足i<=p+R[p],i-R[i]<=p.由于p是递增的,先前满足的以后肯定满足,于是可以用set来维护i-R[i]<=p的所有的位置i的集合,并可在logN的时间内得到最大的位置i. 1 2 3 4 5 6…
Description Problem D The Book-shelver's Problem Input: standard input Output: standard output Time Limit: 5 seconds Memory Limit: 32 MB You are given a collection of books, which must be shelved in a library bookcase ordered (from top to bottom in t…
题目:codeforces 459D - Pashmak and Parmida's problem 题意:给出n个数ai.然后定义f(l, r, x) 为ak = x,且l<=k<=r,的k的个数.求 i, j (1 ≤ i < j ≤ n) ,f(1, i, ai) > f(j, n, aj).,有多少对满足条件的i.j. 分类:逆序数.线段树.离散化, 分析:这是一道不错的数据结构题目,比較灵活. 推一下第一组例子之后发现时让求一个逆序数的题目.可是不是单纯的求逆序数. 第一…
Bob's Problem Accepted : 114   Submit : 589 Time Limit : 1000 MS   Memory Limit : 65536 KB 题目描写叙述 Bob今天碰到一个问题.他想知道x3+y3 = c 是否存在正整数解? 输入 第一行是一个整数K(K≤20000),表示例子的个数. 以后每行一个整数c(2≤c≤109) 输出 每行输出一个例子的结果.假设存在.输出"Yes",否则输出"No".(引號不用输出) 例子输入…
题目链接:http://codeforces.com/contest/459/problem/D D. Pashmak and Parmida's problem time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Parmida is a clever girl and she wants to participate in O…
Shoemaker's Problem Shoemaker has N jobs (orders from customers) which he must make. Shoemaker can work on only one job in each day. For each ith job, it is known the integer Ti (1<=Ti<=1000), the time in days it takes the shoemaker to finish the jo…
题目来源:id=2480" style="color:rgb(106,57,6); text-decoration:none">POJ 2480 Longge's problem 题意:求i从1到n的gcd(n, i)的和 思路:首先假设m, n 互质 gcd(i, n*m) = gcd(i, n)*gcd(i, m) 这是一个积性函数积性函数的和还是积性函数 由欧拉函数知识得 phi(p^a) = p^a - p^(a-1) p是素数 a是正整数 得到终于答案f(n)…
id=1681">http://poj.org/problem? id=1681 求最少经过的步数使得输入的矩阵全变为y. 思路:高斯消元求出自由变元.然后枚举自由变元,求出最优值. 注意依据自由变元求其它解及求最优值的方法. #include <stdio.h> #include <algorithm> #include <set> #include <map> #include <vector> #include <ma…
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak. There is a sequence a that consists of n…
//给一个序列.让求其最大子序列 //这个序列由三段组成.第一段和第二段对称,第一段和第三段一样 //manacher算法求得p[i] //枚举第二段的起点和长度,得到结果 #include<cstdio> #include<cstring> #include<iostream> using namespace std ; const int maxn = 2e5 + 10 ; int str[maxn] ; int p[maxn] ; void pk(int n) {…
Greedy. 证明: Let's say we have job 1, 2, ..., n, and they have time and fine as t1, f1, t2, f2, ..., tn, fn and they are in the order of t1/f1 <= t2/f2 <= t3/f3 <= ... <= tn/fn So this is the objective schedule. Now we change 1 with m (1 < m…
题意: 求f(n)=∑gcd(i, N) 1<=i <=N. 分析: f(n)是积性的数论上有证明(f(n)=sigma{1<=i<=N} gcd(i,N) = sigma{d | n}phi(n / d) * d ,后者是积性函数),能够这么解释:当d是n的因子时,设1至n内有a1,a2,..ak满足gcd(n,ai)==d,那么d这个因子贡献是d*k,接下来证明k=phi(n/d):设gcd(x,n)==d,那么gcd(x/d,n/d)==1,所以满足条件的x/d数目为phi(…
1 Run command “New-SPConfigurationDatabase" Feature Description: error message popup after run function “New-SPConfigurationDatabase". 1.1 Category Code error 1.2 Exception and Phenomena pipeline issue:The pipeline has been stopped New-SPConfigu…
    ID Origin Title   76 / 163 Problem A POJ 1236 Network of Schools   59 / 177 Problem B UVA 315 Network   49 / 151 Problem C UVA 796 Critical Links   28 / 109 Problem D POJ 3694 Network   39 / 98 Problem E POJ 3177 Redundant Paths   33 / 230 Proble…
1 Run command “New-SPConfigurationDatabase" Feature Description: error message popup after run function “New-SPConfigurationDatabase". 1.1 Category Code error 1.2 Exception and Phenomena pipeline issue:The pipeline has been stopped New-SPConfigu…
我打开了#39的problem...想了半个小时多发现我一道题都不会写...于是我打开了#38的problem T1:循环数字的定义为能够将该数划分为若干相同长度的段并且都相同. n=2e18. =>我只会70%的暴力... 正解: 对于[L,R]内的循环整数个数,可以看成是[1,R]内的循环整数个数减去[1,L-1]内的循环整数个数. 对于确定了循环节长度i以及数字长度n的循环整数,在[1,x]内的个数可以用MAX{x div k-10^(i-1)+1,0}算出,其中k是i-1个0,1个1,循…
Source: PAT A1153 Decode Registration Card of PAT (25 分) Description: A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic; the 2nd - 4th digits ar…
Source: PAT A1095 Cars on Campus (30 分) Description: Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, yo…
Hotaru's problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3314    Accepted Submission(s): 1101 Problem Description Hotaru Ichijou recently is addicated to math problems. Now she is playin…
Hotaru's problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1765    Accepted Submission(s): 635 Problem Description Hotaru Ichijou recently is addicated to math problems. Now she is playing…