07 2013 档案

摘要:// Manacher算法,很好用。char s[2*N]; //储存临时串int save[2*N];//中间记录int Manacher(char tmp[]){ int len=strlen(tmp); int cnt=0; for(int i=0;i=p) { int num=1; while(i+num=0&&s[i+num]==s[i-num]) { num++; } p=i+num-1; //能到达的最远位置 ... 阅读全文
posted @ 2013-07-30 22:47 chenhuan001 阅读(491) 评论(0) 推荐(0) 编辑
摘要:可能没有完全读懂题意。个人觉得accaaa答案应该是4.然后就是dp了。。这题数据量小很多方法都可以,数据也水暴力据说都能过。。还有就是我竟然没有用扩展kmp优化下。。。 太无耻了,我是因为找扩展kmp的题才来看这题的。Best SequenceTime Limit:1000MSMemory Limit:10000KTotal Submissions:4217Accepted:1668DescriptionThe twenty-first century is a biology-technology developing century. One of the most attractive 阅读全文
posted @ 2013-07-30 15:49 chenhuan001 阅读(543) 评论(0) 推荐(0) 编辑
摘要:用kmp的方法写了好久,发现以我的想法用kmp不仅难以实现而且无法证明正确性。 于是还是使用扩展kmp。。。Best RewardTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 378Accepted Submission(s): 151Problem DescriptionAfter an uphill battle, General Li won a great victory. Now the head of state decide t 阅读全文
posted @ 2013-07-29 21:46 chenhuan001 阅读(275) 评论(0) 推荐(0) 编辑
摘要:看了扩展KMP的思路,然后来写这题,没有看别人怎么写的,自己写的想死,各种纠结的小细节,而且感觉这个东西自己想是很难想到。终于知找到一道我用kmp无法解决的题目了,只知道用扩展kmp可以搞定。Revolving DigitsTime Limit: 3000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1111Accepted Submission(s): 319Problem DescriptionOne day Silence is interested in revol 阅读全文
posted @ 2013-07-29 09:40 chenhuan001 阅读(438) 评论(0) 推荐(0) 编辑
摘要:不会,题意还是不理解,我感觉选的这个矩形没有一点要按同一个规则摆放吧。 如果是这样真心感觉做不出来。如果不是这样就是简单的kmp。 我是为了练习扩展kmp才来看这题的,结果,。。。貌似扩展kmp也可以做的样子. 但是kmp的做法更好理解吧Milking GridTime Limit:3000MSMemory Limit:65536KTotal Submissions:4859Accepted:2020DescriptionEvery morning when they are milked, the Farmer John's cows form a rectangular grid 阅读全文
posted @ 2013-07-28 16:19 chenhuan001 阅读(264) 评论(0) 推荐(0) 编辑
摘要:母函数分:普通型母函数,指数型母函数。————选自Tanky Woo普通型母函数主要是来求组合的方案数,而指数型母函数是求多重排列数。关于普通型母函数的讲解,以前写过:http://www.wutianqi.com/?p=596而指数型母函数主要是关于排列组合方面的问题。分别看两个比较典型的问题对比:普通母函数问题:有红球两个,白球、黄球各一个,试求有多少种不同的组合方案。指数型母函数问题:假设有8个元素,其中a1重复3次,a2重复2次,a3重复3次。从中取r个组合,求其组合数。下面是指数型母函数的定义:对于上面的问题“假设有8个元素,其中a1重复3次,a2重复2次,a3重复3次。从中取r个组 阅读全文
posted @ 2013-07-23 21:28 chenhuan001 阅读(563) 评论(0) 推荐(0) 编辑
摘要:可以推出公式f[n]=f[n-1]+f[n-1]*2*(n-1)f[1]=1;数据量很大,最后又要进行gcd操作,java里竟然自带了一个gcd的函数,为了避免求大数取余和大数除法操作,还是用java比较快,而且这题对时间复杂度要求不是很高。/* * To change this template, choose Tools | Templates * and open the template in the editor. */import java.math.BigInteger;import java.util.Scanner;/** * * @author chen */public 阅读全文
posted @ 2013-07-19 15:17 chenhuan001 阅读(289) 评论(0) 推荐(0) 编辑
摘要:f[n+1]=(4*n+2)/(n+2)*f[n];由f[n]=C(n,2n)-C(n+1,2n)推导然后就是一些大数乘法和大数除法了。#include #include #include #include #include #include #include #include #include using namespace std;#define INF 0x3fffffff#define base 10000int g[110][110];void mmul(int s[],int tmp,int t[]){ for(int i=0;i=0;i--) { d=s... 阅读全文
posted @ 2013-07-18 21:11 chenhuan001 阅读(305) 评论(0) 推荐(0) 编辑
摘要:与第二类有些区别!#include #include #include #include #include #include #include #include #include using namespace std;#define INF 0x3ffffffftypedef long long int LL;#define N 22LL dp[N][N];LL sum[N];int main(){ //freopen("//home//chen//Desktop//ACM//in.text","r",stdin); //freopen("/ 阅读全文
posted @ 2013-07-17 18:18 chenhuan001 阅读(236) 评论(0) 推荐(0) 编辑
摘要:卡特兰数,第一类斯特林数,第二类斯特林数Catalan数 C(n),第一类Stirling数 s(p,k),第二类Stirling数 S(p,k)[卡特兰数,第一类斯特林数,第二类斯特林数]一.Catalan数 C(n) C(n) 的一个形象的例子是:2*n个括号,其中有n个前括号'('和n个后括号')',排成一列,满足所有括号都匹配的排列数。另一个例子是,n个1和n个-1,共2*n个数,排成一列,满足对所有0=0的排列数。 C(n)的递推公式是 C(n) = ∑(i = 0 : n-1) { C(n-1-i)*C(i) } C(n)的通项公式是 C(n) = 阅读全文
posted @ 2013-07-17 17:51 chenhuan001 阅读(399) 评论(0) 推荐(0) 编辑
摘要:不会斯特林数的只能用递推思想了,结果发现推出来的就是斯特林数。。。#include #include #include #include #include #include #include #include #include using namespace std;#define INF 0x3fffffff#define N 1010#define __int64 long long int#define MOD 1000000007typedef __int64 LL;LL dp[N][N];LL dp1[N][N];int main(){ //freopen("//home/ 阅读全文
posted @ 2013-07-17 11:33 chenhuan001 阅读(265) 评论(0) 推荐(0) 编辑
摘要:完全的乱搞题啊。。。 被坑的要死。拿到题目就觉得是规律题加构造题, 然后找了了几个小时无果,只知道n为奇数的时候是一定无解的,然后当n为偶数的时候可能有很多解,但是如果乱选择的话,很有可能形成无解的情况。然后想到了类似于估价函数之类的东西, 一开始我就想到了让几个关键的点设价值设成很大,然后在构造解的时候尽量不选这些点,然后。。。 发现数据到30左右就出错了。 然后再进一步的想,把每个点都估计一个价值,价值的大小为到0的距离。 然后就可以保证在构造解的时候尽量选离0远的点,这样一直选,一直选,一直选。。。就不可思议的过了。。。不知道具体证明,但是思想感觉没有错误。因为这题无解的情况就是过早的选 阅读全文
posted @ 2013-07-14 18:13 chenhuan001 阅读(362) 评论(0) 推荐(0) 编辑
摘要:二分查找题, 不知道用double的人,用LL果断错了。。。B. Stadium and Gamestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDaniel is organizing a football tournament. He has come up with the following tournament format:In the first several (possibly zero) stages, while th 阅读全文
posted @ 2013-07-14 12:14 chenhuan001 阅读(360) 评论(0) 推荐(0) 编辑
摘要:还没有学过RMQ,所以只能用会的单调队列做。Bob’s RaceTime Limit: 5000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1358Accepted Submission(s): 441Problem DescriptionBob wants to hold a race to encourage people to do sports. He has got trouble in choosing the route. There are N house 阅读全文
posted @ 2013-07-12 10:55 chenhuan001 阅读(318) 评论(0) 推荐(0) 编辑
摘要:处理题目中给的日期,然后用单调队列维护Alice's mooncake shopTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1925Accepted Submission(s): 468Problem DescriptionThe Mid-Autumn Festival, also known as the Moon Festival or Zhongqiu Festival is a popular harvest festiva 阅读全文
posted @ 2013-07-11 23:39 chenhuan001 阅读(394) 评论(0) 推荐(0) 编辑
摘要:一个模式的dp。PearlsTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1096Accepted Submission(s): 476Problem DescriptionIn Pearlania everybody is fond of pearls. One company, called The Royal Pearl, produces a lot of jewelry with pearls in it. The Royal Pe 阅读全文
posted @ 2013-07-11 09:08 chenhuan001 阅读(172) 评论(0) 推荐(0) 编辑
摘要:简单dpMax Sum Plus Plus PlusTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 949Accepted Submission(s): 470Problem Description给定一个由n个正整数组成的整数序列a1 a2 a3 ... an求按先后次序在其中取m段长度分别为l1、l2、l3...lm的不交叠的连续整数的和的最大值。Input第一行是一个整数n(0 ≤ n ≤ 1000),n = 0表示输入结束第二行的第一个 阅读全文
posted @ 2013-07-10 20:11 chenhuan001 阅读(206) 评论(0) 推荐(0) 编辑
摘要:我用的dp是n^3的, dp[i][j] 表示在s串的i个前和t串的j个前,s[i],t[j]为最末端的两个串得到的最大值。状态转移方程为:之前将s和t串最尾端添加'-' for(int i=1;i=0;k--) { dp[i][j]=max(dp[i][j],dp[i-1][k]+tmp); tmp += fuc('-',t[k]); } tmp=0; for(int k=i-1;k>=0;k... 阅读全文
posted @ 2013-07-04 21:02 chenhuan001 阅读(245) 评论(0) 推荐(0) 编辑
摘要:使用一种二进制的优化, 可以完美的解决这题,《背包九讲》中说的非常好但是还有一种线性复杂的算法。 应该算是该题很巧妙的解法for(i=1;i=0;l--) { if(dp[l]==0) continue; for(k=1;k#include #include #include #include #include #include #include #include using namespace std;#define INF 0x3fffffffstruct node{ int w,c;... 阅读全文
posted @ 2013-07-02 13:46 chenhuan001 阅读(368) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示