自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(14)
  • 收藏
  • 关注

原创 斐波那契数列推导及应用

首先:等价于 ..................(1)等价于..................(2)然后:由(1)(2)递推得 ........................(3) ........................(4)其中A,B为常数,由确定最后:由(3)(4)解二元一次方程组得:其中C,D为常数,

2017-07-27 18:13:17 2153

原创 51nod 1113 矩阵连乘快速幂模板 (对100000007取模)

#include #include #include #include #include #define ll long long #define M 1000000007 #define N 2 using namespace std; struct mat { ll m[N][N]; }; mat A= { 1,1,

2017-07-26 23:38:30 1700

原创 快速幂取模 (位优化)

题目:http://acm.nefu.edu.cn/JudgeOnline/problemShow.php?problem_id=517计算ab%k=?(int 10位,longlong 19位)一定不能做完指数运算再求余,因为会溢出。(去掉%k即为快速幂模板)递归:#include #define ll long long using namespace st

2017-07-26 23:09:27 397

原创 hdu 2222 keywords search (AC自动机 模板)

题目:http://acm.hdu.edu.cn/showproblem.php?pid=2222我日,写错好多小细节,还差得远呢。。。#include#include#include#define N 500010char str[1000010],keyword[51];int head,tail;typedef struct node{ struct node*

2017-07-22 18:27:38 153

原创 pku 3461 Oulipo (裸kmp匹配)

题目:http://poj.org/problem?id=3461题意:求W在Z出现的次数。主串   W    A   Z   A   /0                 -1   0   0    1模式串T    A  Z  A  Z  A  Z  Anext可以让其主串中的正确位置与T下一个字符匹配。#include#includeco

2017-07-21 17:08:27 266

原创 hdu 1247 Hat's word

1.我去,分成两个单词的方法竟然这么暴力,挨个试。。。不过很有效,不要一到字符串匹配就kmp,本来写个trie就够长了,再写kmp太复杂,而且根本没法写。所以遇题可以先想想暴力,不行再换别的姿势。2.最坑的地方在于根本不用管输出顺序,因为输入就是字典序,输出必然是。3.trie树还真是空间换时间。长度最多也就30,insert和find就循环30次,所以他敢用暴力套3个for循环,所以就算

2017-07-21 13:01:24 147

原创 hdu 1800 Flying to the Mars (字典树)

1.死循环会给出The limit exceeded,while(scanf("%d",n))别忘了写!=EOF。2.一种字符串加数字的操作,加几会把前面的字符消除几位。#include#include#includetypedef struct node{ struct node*next[10]; bool exist; int count;}*tri

2017-07-20 16:53:08 193

原创 hdu 1075 查火星文(字典树)

1.往回传字符串时,注意返回类型应为指针。2.要注意gets和scanf("%s")不同,是会接受缓存区的回车的。3.怎么改都wa一定是算法问题。#include#include#includetypedef struct node{ struct node*next[26]; bool exist; int count; char wo

2017-07-19 22:19:37 328

原创 hdu 1251 统计难题 (trie树)

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1251不怎么写结构体,这回终于好好复习了下。#include#include#includetypedef struct node{ /*typedef可以将struct node写为简单的trie,node*/ struct node*next[26]; /*指向下个

2017-07-19 17:57:22 221

原创 hdu 2642 Stars(二维数组 单点更新 区间查询)

二维树状数组也是固定写好的,用的时候只要改改main函数就好。#include#include#includeusing namespace std;#define maxn 10000int tree[maxn][maxn],mark[maxn][maxn];int lowbit(int i){ return i&(-i);}void update(in

2017-07-17 23:14:05 191

原创 POJ 2155 矩阵(二维树状数组 区间更新 单点查找)

题目:http://poj.org/problem?id=2155二维树状数组:C[1][1]=a11,C[1][2]=a11+a12,C[1][3]=a13,C[1][4]=a11+a12+a13+a14,,,C[2][1]=a11+a21,C[2][2]=a11+a12+a21+a22,C[2][3]=a13+a23,C[2][4]=a11+a1

2017-07-16 14:08:01 218

原创 POJ 2406 字符串a的n次方 kmp

题目:http://poj.org/problem?id=2406题意:找a的n次方,与s串匹配。#include#includeconst int max=1000005;char str[max];int len,next[max],ans[max];void get_next(){ int i=0,j=-1; next[0]=-1;

2017-07-13 23:55:09 338

原创 pku 2752 取名的小猫 (kmp)

题目:点击打开链接终于学会kmp了。嘻嘻嘻。不过比这更高兴的是看小姐姐学习看了一晚上。好了,小姐姐走了,整理下第一个用kmp写的题。(求小猫起名字?pku的背景都这么怪异?)就是看这篇看会的(写的很棒):http://www.61mon.com/index.php/archives/183/#include#includeconst i

2017-07-09 20:56:01 205

原创 hdu1698 Just a hook (线段树 延迟标记 区间更新)

一个小小的点拖了这么久,好在终于考完试了,能好好做会题了。这题也没自己写了,抄了一份模板。(写的确实比自己好。。)#include#include#includeusing namespace std;#define lchild rt << 1, l, m#define rchild rt << 1 | 1, m + 1, rconst int N=400010;i

2017-07-09 15:55:22 318

空空如也

空空如也

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

TA关注的人

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