01 2016 档案

数论-佩尔方程
摘要:POJ-1320 ZOJ-3759 POJ-2427 HDU-3292 HDU-2281 NBUT-1224 阅读全文

posted @ 2016-01-28 15:10 蓦辰 阅读(261) 评论(0) 推荐(0)

数论-毕达哥拉斯三元组
摘要:方程形式: X^2 + Y^2 = Z^2X,Y,Z即勾股定理的三条直角边。本元毕达哥拉斯的解即三边互质的一组解,如(3,4,5),其求法如下:假定m,n为任意正整数 (m>n) ,满足 gcd(m,n) = 1且m%2 != n%2则:X=m^2-n^2;Y=2*m*n;Z=m^2+n^2;求得本... 阅读全文

posted @ 2016-01-26 14:14 蓦辰 阅读(658) 评论(0) 推荐(0)

HDU 5613-Baby Ming and Binary image
摘要:HDU 5613-Baby Ming and Binary image思路:枚举第一列地雷分布的全部状态,之后可对应逐步推得全图状态。再检查当前全图状态是否可行即可。#include #include #include #include #include #include #include #inc... 阅读全文

posted @ 2016-01-26 12:23 蓦辰 阅读(194) 评论(0) 推荐(0)

ZOJ 2849-Attack of Panda Virus
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2849题意:给定当前网络的病毒感染状态,求最终各编号病毒所能感染的电脑数。给定一张N*M大小的地图(N,M=0时该电脑才能被感染。3、编号小的病毒优先行动,只有低编号... 阅读全文

posted @ 2016-01-25 14:48 蓦辰 阅读(201) 评论(0) 推荐(0)

几何模版-凸包
摘要:Graham算法平均复杂度:N log(N)#include #include #include #include #include using namespace std;const int Max = 1100;#define PI 3.1415926struct Point{ int x... 阅读全文

posted @ 2016-01-25 12:48 蓦辰 阅读(174) 评论(0) 推荐(0)

几何模版-多维最远曼哈顿距离
摘要:/*题意:给定N个D维坐标。求最远曼哈顿距离。解法:对于两个二维坐标A(xi,yi),B(xj,yj).其曼哈顿距离可能为以下四种情况:(xi-xj)+(yi-yj), (xj-xi)+(yi-yj), (xi-xj)+(yj-yi), (xj-xi)+(yj-yi)将坐标参数按点来分配之后变形如下... 阅读全文

posted @ 2016-01-25 11:12 蓦辰 阅读(1228) 评论(0) 推荐(0)

BFS-修改范例-开门系列-单扇多类门配多钥匙
摘要:/*BFS:多类单个门,配多把钥匙*/#include #include #include #include #include #include #include #include #include #include using namespace std;#includeconst int INF... 阅读全文

posted @ 2016-01-25 11:09 蓦辰 阅读(225) 评论(0) 推荐(0)

BFS-修改范例-状态压缩
摘要:/*BFS:二进制状态压缩*/#include #include #include #include #include #include #include #include #include #include using namespace std;#define MAXN 11111#includ... 阅读全文

posted @ 2016-01-25 11:08 蓦辰 阅读(231) 评论(0) 推荐(0)

BFS-修改范例-重点访问
摘要:/*BFS:重复访问类关键:对每个点的访问与否取决于到达该点的条件的优劣(本题关键在于访问该点是能量的多少,比原先多的即可走)*/#include #include #include #include #include #include #include #include #include #inc... 阅读全文

posted @ 2016-01-25 11:07 蓦辰 阅读(236) 评论(0) 推荐(0)

BFS-基础模版
摘要:/* 小水题当个模版*/#include #include #include #include #include #include using namespace std;#include #include #include #include #include #define M 1000 ... 阅读全文

posted @ 2016-01-25 11:06 蓦辰 阅读(171) 评论(0) 推荐(0)

字符串-最长回文子串O(n)
摘要:#include#include#include#include#includeusing namespace std;const int MAXN=110010;char s[2*MAXN];//MAXN太大只能放外面int p[MAXN*2];//求给定字符串str的最长回文子串int solv... 阅读全文

posted @ 2016-01-25 11:04 蓦辰 阅读(257) 评论(0) 推荐(0)

图论-最短路模版
摘要:Dijkstra算法-邻接矩阵形式复杂度:N^2/** Dijkstra算法,邻接矩阵形式:* 复杂度为O(n^2),仅可处理非负权图* cost: 任意两点边权(不相连边需赋值INF)* n: 图中点的总数(当前点从0开始编号)* lowcost:任意点到源点的最短路* beg:... 阅读全文

posted @ 2016-01-25 11:02 蓦辰 阅读(212) 评论(0) 推荐(0)

图论-最小生成树模版
摘要:Kruskal 算法复杂度:E log(2E)int F[MAXN];//并查集使用struct Edge{ int u,v,w;}edge[MAXM];//存储边的信息,包括起点/终点/权值int tol;//边数,加边前赋值为0void addedge(int u,int v,int w)... 阅读全文

posted @ 2016-01-25 10:55 蓦辰 阅读(179) 评论(0) 推荐(0)

图论-并查集模版
摘要:#includeint father[1005];int find(int x){ int r=x; while(father[r]!=r) {//沿着关系一直向上摸索 r=father[r]; } int i=x,k; //压缩 while(... 阅读全文

posted @ 2016-01-25 10:53 蓦辰 阅读(146) 评论(0) 推荐(0)

数论-矩阵快速幂模版
摘要:#include #include #include #include #include #include using namespace std;#define M 20int num, mod;//定义矩阵结构体struct mat{ int at[M][M];};struct mat d... 阅读全文

posted @ 2016-01-25 10:50 蓦辰 阅读(146) 评论(0) 推荐(0)

数论-GCD && 欧拉函数 && 快速求幂
摘要:int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}int Euler(int n){ //给定n,返回1~~(n-1)中与n互质的数的个数 //复杂度nlogn int i; int result;... 阅读全文

posted @ 2016-01-25 10:49 蓦辰 阅读(162) 评论(0) 推荐(0)

数论-O(N)打印素数表
摘要:#include#include#include#include#includeusing namespace std;#define MAXPRME 100000bool visit[MAXPRME+100];int prime[MAXPRME];//给定n,求所有>n) { ... 阅读全文

posted @ 2016-01-25 10:47 蓦辰 阅读(217) 评论(0) 推荐(0)

划分树-修改范例
摘要:/*HDU 3473 Minimum Sum求询问区间内 所有数与中位数的差的绝对值的和*/#include#include#include#includeusing namespace std;const int MAXN=200010;int tree[20][MAXN];int sorted... 阅读全文

posted @ 2016-01-25 10:46 蓦辰 阅读(242) 评论(0) 推荐(0)

划分树-模版(求区间第K大)
摘要://复杂度log(n)#include #include #include #include #include #include #include #include #include #include #include #includeusing namespace std;#include con... 阅读全文

posted @ 2016-01-25 10:44 蓦辰 阅读(279) 评论(0) 推荐(0)

输入挂
摘要:简化版:(正int输入挂)int read(){ char ch=' '; int ans=0; while(ch'9') ch=getchar(); while(ch='0') { ans=ans*10+ch-'0'; ch=... 阅读全文

posted @ 2016-01-25 10:43 蓦辰 阅读(164) 评论(0) 推荐(0)

线段树-区间查询模版
摘要:/**模版原题:PKU 3468*线段树*区间求和*/#include #include using namespace std;#define lson l , m , rt > 1)); // sum[rt*2]+=( add值*其旗下最终子节点个数); sum... 阅读全文

posted @ 2016-01-25 10:35 蓦辰 阅读(228) 评论(0) 推荐(0)

线段树-单点更新模版
摘要:/***模版原题:HDU 1754*线段树-单点加减*区间求最值*/#include #define lson l , m , rt > 1; //m=(l+r)/2; build(lson); build(rson); PushUP(rt); //回溯更新父节点}//单点修... 阅读全文

posted @ 2016-01-25 10:34 蓦辰 阅读(137) 评论(0) 推荐(0)

C++大数模版
摘要:#include #include using namespace std;#define DIGIT 4 //四位隔开,即万进制#define DEPTH 10000 //万进制#define MAX 251 //题目最大位数/4,要不大直接设为最大位... 阅读全文

posted @ 2016-01-25 10:31 蓦辰 阅读(172) 评论(0) 推荐(0)