自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

YRC1993的专栏

Never give up!

  • 博客(21)
  • 收藏
  • 关注

原创 SPOJ 1812. Longest Common Substring II(后缀自动机)

借鉴然哥的  http://blog.csdn.net/zz_1215/article/details/8053262#include #include #include using namespace std;const int maxn = 200005;const int maxc = 26;const int inf = 1<<30;int go[maxn][26];

2013-08-13 22:17:03 939

原创 SPOJ 1811 Longest Common Substring(后缀自动机)

存个模板,感谢然哥的模板#include #include #include using namespace std;const int maxn = 500005;const int maxc = 26;int go[maxn][26];int len[maxn];int f[maxn];class suffix_automaton{ public: const

2013-08-13 18:17:40 792

原创 HDU4578 Transformation(裸线段树)

//先处理乘再处理加 #include using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define mlson rt<<1#define mrson rt<<1|1const int maxn = 100005;const int mod = 10007;int n,m;int s

2013-08-11 13:43:10 760

原创 HDU 4655 Cut Pieces

/*题意:输入一组n长的序列ai,表示n个格子的各自能涂的颜色数,颜色为1~ai。求找出ai的一种 排列,使得所有颜色组合的sum和最大,sum表示一种颜色组合的片数,连续的相同颜色算一片, 输出最大的sum和 c=n*s-(s/min(b1,b2)+s/min(b2,b3)+...+s/min(bn-1,bn))(a/b)%mod(a%mod*pow(b,mod-2))%mod

2013-08-09 21:43:51 655

原创 HDU 4333 Revolving Digits (扩展KMP)

#include #include #include using namespace std;const int maxn = 200005;char str[maxn];char tmp[maxn/2];int next[maxn];int ex[maxn];int ep[maxn];void get_next(char *s,int len){ next[0

2013-08-09 10:36:52 595

原创 POJ 2778 DNA Sequence (AC自动机)

题意:检测所有可能的n位DNA串有多少个DNA串中不含有指定的病毒片段思路:ac自动机+矩阵快速幂,具体请参考http://hi.baidu.com/ccsu_010/item/7847a3c17f6fe2bc0d0a7b89感谢然哥的ac自动机的模版 http://blog.csdn.net/zz_1215/article/category/1145295#include #i

2013-05-18 14:17:13 481

原创 POJ3368 Frequent values

题意:给定一个非降序的数列,然后进行查询操作,问范围 [l,r] 内出现频率最高的数字出现了多少次思路:RMQ  //a[i]表示左边与data[i]相同的节点数(包括自己);b[i]表示右边与data[i]相同的节点数(包括自己)#include #include #include using namespace std;#define maxn 100005int d

2013-05-05 22:36:56 512

原创 ZOJ 3686 : A Simple Tree Problem

题意:给出一棵树,做 M 次操作,每次要么将一棵子树上每个结点的布尔值取反,要么查询一棵子树上布尔值为 true 的个数思路:先 dfs 将树转化成一个序列,然后用线段树维护,区间修改/区间查询 #include #include using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1cons

2013-04-05 14:45:26 574

原创 POJ 1845 Sumdiv

题意:求A^B的所有约数之和,并对其取模 9901。定理:(1) 整数的唯一分解定理:      A=(p1^k1)*(p2^k2)*(p3^k3)*....*(pn^kn)   其中pi均为素数(2) 约数和公式:    对于已经分解的整数A=(p1^k1)*(p2^k2)*(p3^k3)*....*(pn^kn)    A的约数和为S = (1+p1

2013-01-23 00:03:59 485

原创 POJ 3273 Monthly Expense

题意:给你天数n,和每天需要花的钱,让你把这些天分成m份(每份都是连续的天),要求每份的和尽量少,输出这个和。思路:二分#include using namespace std;#define maxn 100000int day[maxn];int n,m;int solve(int low,int high){ if(low==high) return low; in

2013-01-18 17:16:19 950

原创 POJ 1222 EXTENDED LIGHTS OUT

高斯消元模版题,但怎样建立方程组不容易想,请参考http://blog.csdn.net/shiren_Bod/article/details/5766907#include using namespace std;#define hmax 30#define lmax 30int map[hmax][lmax+1];int ans[lmax];inline int gcd(in

2013-01-17 02:06:39 447

原创 POJ2992 Divisors

//求C(n,k)约数个数//先用cin TLE了,改用scanf  提交c++ 过了#include #include #include #include using namespace std;#define maxn 500vector a[432];bool prime[maxn];int b[432];void findprime()

2012-11-26 21:51:38 685

原创 POJ 2689 Prime Distance

区间筛选素数#include using namespace std;#define ll long long#define inf 999999999#define maxn 50001bool prime[maxn];bool flag[1000001];void findprime(){ memset(prime,true,sizeof(prime));

2012-10-24 17:31:59 505

原创 POJ 2034 Anti-prime Sequences

素数筛选+dfs #include #include #include using namespace std;#define maxn 10005int flag[maxn];bool vis[1005];int a[1005];int n,m,d,cur,judge;void prime(){ for(int i=2;i*i<maxn;i++) {

2012-10-21 22:20:01 517

原创 ZOJ 3665 Yukari's Birthday

枚举r二分k #include #include #include #define ll long longusing namespace std;ll n,r;ll pow1(ll mid,ll r){ ll t=1; for(ll i=1;i<=r;++i) { t*=mid; } return t;}ll so

2012-10-18 23:21:50 889

原创 HDU 1054 Strategic Game

//最小顶点覆盖数=最大匹配数#include #include const int maxn=1501;int k;int map[maxn][maxn];int xlink[maxn],ylink[maxn];bool visit[maxn];int le[maxn];bool find(int u){ for(int i=0; i<le[u]; ++i)

2012-08-26 20:46:19 458

原创 HDU 2063 过山车

二分图最大匹配(匈牙利算法DFS)#include #include const int maxn=505;int un,vn;bool map[maxn][maxn];int xlink[maxn],ylink[maxn];bool visit[maxn];bool find(int u){ for(int v=1; v<=vn; ++v) {

2012-08-26 18:52:53 622

原创 空间四点确定球心坐标(克莱姆法则)

void get_xyz(double x1,double y1,double z1, double x2,double y2,double z2, double x3,double y3,double z3, double x4,double y4,double z4, double &x,d

2012-08-25 22:31:01 9919

原创 HDU 4266 The Worm in the Apple

三维凸包模版(ps:不知哪位神牛写的。。膜拜)+暴力#include#include#include#define eps 1e-7#define MAXV 1005using namespace std;//三维点struct pt{ double x, y, z; pt(){} pt(double _x, double _y, double _z):

2012-08-25 22:20:41 803

原创 HDU 1028 Ignatius and the Princess III

#include using namespace std;int main(){ int a[122][122],n,i,j; memset(a,0,sizeof(a)); a[1][0]=1; a[1][1]=1; a[2][0]=2; a[2][1]=1; for(i=3;i<=120;++i) { fo

2012-08-23 22:08:24 419

原创 HDU 1042 N! + HDU1018 Big Number

大数阶乘。。(0=Striling公式可得N阶乘近似值:                                              所以n!的位数 f(n) = [log10(n!)]+1 = floor{ 0.5*log10(2*pi)+(0.5+n)*log10(n)-n*log10(e) }+1  #include #include using n

2012-08-07 23:05:13 1322

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除