- 博客(16)
- 收藏
- 关注
原创 【NOIP模板】 莫队(分块)
#include <cmath> #include <cstdio> #include <cstring> #include <algorithm> using namespace std;const int N = 100010;struct Node { int l, r, bl, id; } q[N];bool cmp(const Node &a, const Node &b) {
2017-09-28 16:13:01 264
原创 【NOIP模板】 堆-stl
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std;long long ans = 0; int t, n, a[100010];int main() { scanf("%d", &n); for(int i = 1; i <= n; i +
2017-09-28 16:10:20 252
原创 【NOIP模板】 gcd & lcm
#include <cstdio> #include <cstring> #include <algorithm> using namespace std;int a, b;int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }int main() { scanf("%d %d", &a, &b); printf("%
2017-09-22 21:35:26 285
原创 【NOIP模板】 trie树
#include <cstdio> #include <cstring> #include <algorithm> using namespace std;struct Trie { int num; bool excit; Trie *child[26]; } pool[100010], *tail = pool, *root; int ans, n, m, num = 0
2017-09-22 19:28:11 193
原创 【NOIP模板】 线段树
#include <cstdio> #include <cstring> #include <algorithm> using namespace std;char s[10]; int a[1000000], root, n, T;struct Node { int sum, flag; } t[1000000];void pushdown(int root, int L, int R)
2017-09-22 18:33:10 205
原创 【NOIP模板】 树状数组
#include <cstdio> #include <cstring> #include <algorithm> using namespace std;char s[10]; int t[50010], a[50010], n, T;int lowbit(int x) { return x & (- x); }void add(int x, int pos) { while(po
2017-09-22 16:27:56 177
原创 【NOIP模板】KMP
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; int T, nxt[1000050], lens, lent; char s[1000050], t[1000050]; void init() { int i = 0, j = -1; nxt[0] = -1; wh
2017-09-16 17:36:26 274
原创 【NOIP模板】 树链剖分 (求lca)
#include <cstdio> #include <cstring> #include <algorithm> using namespace std;struct Edge { int v, next; } edge[20050];int T, n, a, b, num, head[20050];int fa[10050], son[10050], siz[10050], vis[10
2017-09-15 22:05:34 198
原创 【NOIP模板】 tarjan
#include <cstdio> #include <cstring> #include <algorithm> using namespace std;struct Edge { int u, v, next; } edge[100010];int n, m, num = 0, in[100010], out[100010], head[100010];int top = 0, cnt
2017-09-15 21:28:47 177
原创 【NOIP模板】 并查集
#include <cstdio> #include <cstring> #include <algorithm> using namespace std;int n, m, p, r1, r2, fa[50010];int find(int x) { if(fa[x] == x) return x; return fa[x] = find(fa[x]); }int main() {
2017-09-15 20:51:16 273
原创 【NOIP模板】 最短路 spfa
#include <cstdio> #include <cstring> #include <algorithm> using namespace std;struct Edge { int w, v, next; } edge[20010];int t, c, s, e, num = 0, vis[20010], dis[20010], queue[20010], head[20010];
2017-09-15 20:50:13 192
原创 【NOIP模板】 最小生成树 kruskal
#include <cstdio> #include <cstring> #include <algorithm> using namespace std;int n, w, num = 0, head[100010], fa[1010];struct Edge { int u, v, w, next; } edge[100010];void add(int u, int v, int w)
2017-09-15 20:34:27 191
原创 阿柟的NOIP冲刺计划
/*本计划旨在通过励精图治发愤图强通过不懈努力最终拿到NOIP一等奖。*/ 基础篇 ·贪心 ·二分 ·模拟 ·暴力 动态规划篇 ·普通dp ·背包dp ·期望dp 图论篇 ·最短路 ·最小生成树 ·并查集 ·树链剖分 ·二分图 ·tarjan ·拓扑排序 ·dfs序 ·点分 数论篇 ·gc
2017-09-15 20:30:14 193
原创 hdu 1847 Good Luck in CET-4 Everybody! (博弈论)
Problem Description大学英语四级考试就要来临了,你是不是在紧张的复习?也许紧张得连短学期的ACM都没工夫练习了,反正我知道的Kiki和Cici都是如此。当然,作为在考场浸润了十几载的当代大学生,Kiki和Cici更懂得考前的放松,所谓“张弛有道”就是这个意思。这不,Kiki和Cici在每天晚上休息之前都要玩一会儿扑克牌以放松神经。 “升级”?“双扣”?“红五”?还是“斗地主”?
2017-09-03 21:49:09 232
原创 hdu 1848 Fibonacci again and again (博弈论)
Problem Description任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的: F(1)=1; F(2)=2; F(n)=F(n-1)+F(n-2)(n>=3); 所以,1,2,3,5,8,13……就是菲波那契数列。 在HDOJ上有不少相关的题目,比如1005 Fibonacci again就是曾经的浙江省赛题。 今天,又一个关于
2017-09-03 21:35:41 193
原创 9.2机房欢乐赛 礼物 (状态压缩+期望dp)
礼物(gift.cpp\c\pas)【问题描述】夏川的生日就要到了。作为夏川形式上的男朋友,季堂打算给夏川买一些生日礼物。 商店里一共有种礼物。夏川每得到一种礼物,就会获得相应喜悦值Wi(每种礼物的喜悦值不能重复获得)。 每次,店员会按照一定的概率Pi(或者不拿出礼物),将第i种礼物拿出来。季堂每次都会将店员拿出来的礼物买下来。没有拿出来视为什么都没有买到,也算一次购买。 众所周知,白毛切开都
2017-09-02 15:55:13 434
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人