自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(8)
  • 问答 (1)
  • 收藏
  • 关注

原创 KMP算法

模板:char s1[1000005];char s2[1005];int p[10005];int l1,l2;void init(){ int i,j; i=0; l2 = strlen(s2); j=-1; p[0]=-1; while(i<l2) { if(j==-1||s2[i]==s2[j]

2015-08-25 23:36:50 297

原创 poj 2689 Prime Distance 筛素数加强版

这题敲得我好感人啊,踌躇了几天,终于干掉它了#include#include#includeusing namespace std;typedef long long ll;ll l,u;ll a[50010];ll b[50010];ll c[1000100];ll d[1000100];ll k = 0;void init(){ ll i,j;

2015-08-16 20:10:37 509

原创 poj 2142 The Balance 数论-扩展欧几里得

扩展欧几里得算法应用#includeusing namespace std;int x,y,d;int exgcd(int a,int b,int &x,int &y){ if(b == 0) { x = 1; y = 0; return a; } int d = exgcd(b,a%b,y,x);

2015-08-15 12:56:49 375

原创 求最大匹配之匈牙利算法

模板:int vis[N];int edge[N][N];int link[N];int maxmatch;bool dfs(int x){ int v; for(v=1; v<=n; v++) { if(vis[v]==1&&edge[x][v]) { vis[v]=1; if(link[v]==-1||dfs(link[v])) {

2015-08-12 22:32:08 327

原创 poj 3126 Prime Path

直接暴力广搜所有可能的情况,先等于的就是最短的,用vis[]数组标记访问过的数字,搜索的姿势我是这样的,改变每一位上的数的值,放进队列。而且最终一定存在这样的路径,然而,不能给出证明#include#include#includeusing namespace std;int x,y;int vis[10010];struct point{ int x;

2015-08-11 09:24:14 263

原创 c++ stl

c++ 中的multiset,默认最小值,要取最大值,要重新声明一个类,并重载,在多校联合中,看到有重载()的,借用了一下,发现还真能行.题目:hdu 5349#includeusing namespace std;const int inf = 0x3f3f3f3f;struct classCompare{ bool operator()(const int

2015-08-09 23:59:13 576

原创 poj 2236Wireless Network 并查集

好久没写过并查集了,居然1A,纪念一下#include#includeusing namespace std;int n,m;struct point{ int x,y;}p[1002];int vis[30030];int fa[300000];int findd(int x){ int s; for(s = x;s!=fa[s];s=f

2015-08-09 20:27:00 350

原创 poj 1840 Eqs 哈希散列

哈希的一血#include#include#includeusing std::cout;using std::endl;const int mod = 139997;int hash[140000];int cot=0;int a[140000][100];inline void insert(int ans){ int he = (ans%mod+m

2015-08-05 13:41:34 325

空空如也

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

TA关注的人

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