- 博客(22)
- 资源 (1)
- 收藏
- 关注
原创 BestCoder Round #14 03 Harry And Math Teacher (线段树)
http://acm.hdu.edu.cn/showproblem.php?pid=5068题意:
2014-10-19 18:55:58 470
原创 (模板)dlx 精确覆盖和重复覆盖
精确覆盖#define mxn 1120#define N 1000200int n, m, t, size;int U[N], D[N], L[N], R[N], C[N], Row[N];int H[mxn], S[mxn];void init(int n, int m) { for(int i = 0; i <= m; ++i) { S[i] = 0, D[i] =
2014-10-15 11:26:05 1145
原创 (模板)逆元
int exgcd(int a, int b, int &x, int &y) { int d = a; if(b != 0) { d = exgcd(b, a % b, y, x); y -= a / b * x; } else x = 1, y = 0; return d;}int mod_inverse(int a, int m) { int x, y; exgcd
2014-10-14 21:45:45 655
原创 (模板) MCMF SPFA
struct edge { int u, v, cap, flow, cost, nxt; void set(int _u, int _v, int _cap, int _flow, int _cost, int _nxt) { u = _u, v = _v, cap = _cap, flow = _flow, cost = _cost, nxt = _nxt; }};struct
2014-10-14 21:34:27 1175
原创 (模板)isap
struct edge { int u, v, cap, flow, nxt; void set(int _u, int _v, int _cap, int _flow, int _nxt) { u = _u, v = _v, cap = _cap, flow = _flow, nxt = _nxt; }};struct isap { int n, s, t, fst[mxn],
2014-10-14 20:46:36 497
原创 (模板) dinic
#define mxn 100020#define mxe 200020#define inf 0x3f3f3f3fstruct edge { int u, v, cap, flow, nxt; void set(int _u, int _v, int _cap, int _flow, int _nxt) { u = _u, v = _v, cap = _cap, flow = _
2014-10-14 00:01:07 610
原创 (模板)米勒罗宾素数测试
LL prime[6] = {2, 3, 5, 233, 331};LL qpow(LL a, LL n, LL mod) { LL ret = 1; while(n) { if(n & 1) ret = ret * a % mod; a = a * a % mod; n >>= 1; } return ret;}bool Miller_Rabin(LL p) { if
2014-10-13 23:20:39 5946
原创 (模板)广义fib循环节
// f(n) = a * f(n - 1) + b * f(n - 2);// f(1) = c, f(2) = d // 可忽略// 求f(n)mod p循环节长度//c = a * a + 4b是模p的二次剩余时,枚举n = p - 1的因子// 否则 枚举n=(p+1)(p-1)的因子// 这里 p = 1000000007#include #include #in
2014-10-13 23:19:10 761
原创 (模板)Fib循环节
#include #include #include #include #include using namespace std;#define LL long longconst int M = 2;struct mat { LL a[M][M];};mat A, I = {1, 0, 0, 1};mat multi(mat a, mat b, LL mod) {
2014-10-13 23:18:36 529
原创 (模板)treap
struct node { int ch[2], r, v, s, cnt; node() {} node(int v):v(v) { ch[0] = ch[1] = 0, r = rand(), s = 1; cnt = 1; }}p[mxn*20];int sz;int creat(int v) { ++ sz; p[sz] = node(v); return sz
2014-10-13 23:14:39 568
原创 (模板)splay
#define mxn 200020#define ls (p[i].ch[0])#define rs (p[i].ch[1])struct node { int ch[2], val, s; void set(int x) { ch[0] = ch[1] = 0; val = x, s = 1; }}p[mxn];int sz;void down(int i){ //
2014-10-13 23:14:24 461
原创 (模板)后缀数组(lcp和rmq)
char s[mxn];int sa[mxn], t[mxn], t2[mxn], c[mxn], f[mxn][20], ft[mxn];int Rank[mxn], height[mxn];void get_sa(int m, int n) { //n = strlen(s) + 1; int i, *x = t, *y = t2; for(i = 0; i < m; ++i) c
2014-10-13 23:09:49 659
原创 (模板)AC自动机
struct trie { int ch[mxnode][26], lst[mxnode], cnt[mxnode], f[mxnode], sz; int creat() { memset(ch[sz], -1, sizeof(ch[sz])); cnt[sz] = 0; return sz++; } void init() { sz = 0, creat(); }
2014-10-13 23:09:24 499
原创 (模板)KMP
char t[mxn], s[mxn]; //t模板串,下标0开始int f[mxn], n;void get_f() { f[0] = f[1] = 0; for(int i = 1; t[i]; ++i) { int j = f[i]; while(j && t[i] != t[j]) j = f[j]; f[i+1] = t[i] == t[j]? j + 1: 0;
2014-10-13 23:08:54 444
原创 (模板)c++ 大数(正数加减乘除)
char ip[mxn];struct bign { int len, dig[mxn]; bign() { len = 0, dig[0] = 0; }bool input() { if(scanf("%s", ip) == EOF) return 0; if(strcmp(ip, "0") == 0)
2014-10-13 23:06:07 944
原创 (模板)JAVA 大数的使用
import java.util.*;import java.math.*;public class Main { public static void main(String args[]) { int a = 102; BigInteger x = BigInteger.valueOf(a); Scanner cin = new Scanner(System.in);
2014-10-13 23:06:01 566
原创 acdream 1124 喵喵的遗憾 fib循环节
#include #include #include #include #include using namespace std;#define LL long longconst int M = 2;struct mat { LL a[M][M];};mat A, I = {1, 0, 0, 1};mat multi(mat a, mat b, LL mod) {
2014-10-08 22:04:03 677
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人