上一页 1 2 3 4 5 6 7 ··· 20 下一页
摘要: // 原串最大长度N// 返回最大回文字串 res#include<cstdio>#include<cstring>#include<cstdlib>#include<string>#include<algorithm>using namespace std;const int N = 1024;int rid[N<<2];string manacher(char *s){ string t, res; int L = strlen(s); // init t += '?'; for(int i = 0; 阅读全文
posted @ 2013-05-20 12:00 yefeng1627 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 算法内容http://blog.sina.com.cn/s/blog_70811e1a01014esn.html题目直接看输出即可, 注意前后放 ? #, #*. 然后找最大回文串长度应该是 rid[i]*2 + (str[i] =='#')#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>#include<string>using namespace std;const int N = 1024;char s[N];int rid 阅读全文
posted @ 2013-05-20 11:45 yefeng1627 阅读(207) 评论(0) 推荐(0) 编辑
摘要: hdu 4548 美素数 用线性筛法筛选出10^6的素数,然后预处理统计下.. O(1)就能得到结果了.#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>using namespace std;const int N = (int)1e6+10;bool vis[N];int p[N], sum[N];void GetPrime(){ memset(vis,0,sizeof(0)); vis[1] = 1; int cnt = 0; for(int i = 2 阅读全文
posted @ 2013-05-19 16:31 yefeng1627 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 弱到一定程度了... 不过还好.又涨经值和姿势了.....hdu 4551 生日猜猜猜 月份和日期都比较小, (12,31) 果断暴力, 然后判定下当前月份和天数是否合法.#include<cstdio>#include<cstdlib>#include<cstring>using namespace std;int day[2][13] = { {0,31,28,31,30,31,30,31,31,30,31,30,31 } ,{0,31,29,31,30,31,30,31,31,30,31,30,31 }};int gcd(int a,int b){ r 阅读全文
posted @ 2013-05-19 14:34 yefeng1627 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 训练赛链接:http://openoj.awaysoft.com:8080/judge/contest/view.action?cid=424#overview题目来源:The 10th Zhejiang Provincial Collegiate Programming Contest还是想吐嘈 ZOJ的题目描述,与模拟题的恶心程度........AApplications 背景是ACM集训队选拔,根据OJ题数,区域赛获奖,CF/TC排名, 还有个性别, 注意的地方是CF不满三场不计算.#include<cstdio>#include<cstring>#include 阅读全文
posted @ 2013-05-18 17:13 yefeng1627 阅读(565) 评论(2) 推荐(0) 编辑
摘要: 本质上是暴力模拟计算,逐位统计、以及如何寻找不被约束的状态来简化计算 是关键点。例题1 ural 1057. 1.树形结合, 按位统计. 若当前位为1, 则取0, 剩下的位任意取都比其小, ans += f[ L ][ k-tot ], L表示剩下长度. 论文这个地方写的感觉不对- -...#include#include#include#include#includeusing namespace std;int f[32][32];void init(){ memset(f,0,sizeof(f)); f[0][0] = 1; for(int i = 1; i ... 阅读全文
posted @ 2013-05-17 13:55 yefeng1627 阅读(1407) 评论(0) 推荐(0) 编辑
摘要: 参考论文:郭华阳《RMQ与LCA问题》 的解法.通过构建最小生成树,然后转换成 寻找最近公共祖先来求解, 逆序处理询问,将删除改成添加边.代码在BZOJ上WA了.暂时未找到原因, 先放着... 不过有看到用splay, 动态树等做的..#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>#include<map>#include<vector>using namespace std;const int N = (int)1e5+10;co 阅读全文
posted @ 2013-05-16 19:49 yefeng1627 阅读(649) 评论(0) 推荐(0) 编辑
摘要: 题目源自 XTUhttp://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1170Coins题意: 有编号为1到10^9个盒子,每个盒子为空或装部分球,现在给K个区间,形如[ L, R , num ] 表示编号为 L到R的盒子中至少有num个球,求所有盒子装球的最小数量和。线段树解法 其实不难想到解法,我们依据c的值从小到大覆盖指定区间,若出现当前区间被完整覆盖时,则意味着冲突,应该为 "Error",否则求和。重要的是如何实现,区间覆盖问题,是线段树(segment Tree)的强项。 我们且先,假定盒子数量 阅读全文
posted @ 2013-05-15 15:49 yefeng1627 阅读(419) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1208题意: 中文题就不说了,都能看明白解法: 数据结构题,应该使用一个BST类型的数据结构来实现,bst,treap,avl,splay,sbt,等等都可以。 我的解法是维护两个 spaly tree,A表示宠物,B表示收养者, 对于 a = 0, 添加宠物时, 首先检查 B是否为空, 若执行 A.insert( a ), 否则,调用方法 B.deal( a ). deal( val ) 的思路: 若B中原本就有val值,则花费为0,直接删除key[x]=val的节点。 否则插... 阅读全文
posted @ 2013-05-14 21:09 yefeng1627 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 全文资料来自wiki:http://en.wikipedia.org/wiki/Cyclic_numberCyclic numberCyclic Number 是一个整数是,且其连续的倍数 (1,2,..,L-1) ,是其本身数字的一个循环。 常见的如下142857 × 1 = 142857142857 × 2 = 285714142857 × 3 = 428571142857 × 4 = 571428142857 × 5 = 714285142857 × 6 = 857142而形如下非连续的倍数不是076923 × 1 = 阅读全文
posted @ 2013-05-14 10:56 yefeng1627 阅读(285) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 20 下一页

Launch CodeCogs Equation Editor