- 博客(45)
- 收藏
- 关注
原创 【ZOJ2334】Monkey King
题目大意有 n(n≤105)n(n≤10^5) 只猴子,初始每只猴子为自己猴群的猴王,每只猴子有一个初始的力量值。这些猴子会有 mm 次会面。每次两只猴子 x,yx,y 会面,若 x,yx,y 属于同一个猴群输出 −1−1 ,否则将 x,yx,y 所在猴群的猴王的力量值减半,然后合并这两个猴群。新猴群中力量值最高的为猴王。输出新猴王的力量值。简要分析我们需要一种数据结构维护元素,支持快速合并,查找最
2015-08-25 00:25:56
762
原创 SGU171:Sarov zones
贪心,将W从大到小排序,每次选P-Q最小的。#include <set>#include <map>#include <ctime>#include <cmath>#include <queue>#include <cstdio>#include <cctype>#include <vector>#include <cstring>#include <iostream>#incl
2015-08-24 00:27:21
433
原创 Uva12716:GCD XOR
Given an integer N, find how many pairs (A, B) are there such that: gcd(A, B) = A xor B where 1 ≤ B ≤ A ≤ N. Here gcd(A, B) means the greatest common divisor of the numbers A and B. And A xor B is th
2015-08-23 16:37:25
532
原创 NOIP2011:数的划分
【题目描述】将整数n分成k份,且每份不能为空,任意两种划分方案不能相同(不考虑顺序)。 例如:n=7,k=3,下面三种划分方案被认为是相同的。 1 1 5 1 5 1 5 1 1 问有多少种不同的分法。【简要题解】如果我们想将一个数n分成k份,那么可以将方案分为两类: 1.至少包含一份1 2.一份1都不包含(也就是均大于1) 于是我们可以先将n-1分成k-1份,再加一份1进去。(对应
2015-08-23 15:45:44
501
原创 Treap
各种模板到处飞。。。 lrj版#include<cstdlib>struct Node { Node *ch[2]; // 左右子树 int r; // 随机优先级 int v; // 值 int s; // 结点总数 Node(int v = 0):v(v) { ch[0] = ch[1] = NULL; r = rand(); s = 1; } int cmp(int
2015-07-10 21:37:41
299
原创 线段树
线段树模板啦 维护区间和,最大值,最小值 资瓷区间加值,区间赋值#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int INF = 0x3f3f3f3f;const int maxn = 105;int a[maxn];int add[maxn << 2], col[maxn
2015-07-10 21:33:28
386
原创 hdu2222
AC自动机模板#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int MAXN = 240005;const int MAXL = 1000005; struct ACM{ int ch[MAXN][26], cnt[MAXN], f[MAXN], last[MAX
2015-07-10 21:29:44
366
转载 lower_bound
template <class ForwardIterator, class T>ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, const T& val){ ForwardIterator it; iterator_traits<ForwardIterator>::differe
2015-07-10 21:10:24
313
原创 July list
[7.3] sgu147(区间求交) sgu148(枚举 堆优化) sgu149(树形DP) sgu150(枚举)[7.4] sgu151(数学) sgu152(大水题)[7.5] sgu153(打表找规律) NOIP2009靶形数独(搜索 顺序很重要)
2015-07-09 22:01:01
325
原创 Hello World
不知道为什么,突然想写一个Hello World。 其实是因为想起了一首诗。《我将归来开放》李敖因为我从来是那样所以你以为我永远是那样可是这一回你错了我改变得令你难以想象坏的终能变得好弱的总会变得壮谁能想到丑陋的一个蛹却会变成翩翩的蝴蝶模样像一朵入夜的荷花像一只归巢的宿鸟或像一个隐居的老哲人我消逝了我所有的锋芒与光亮漆黑的隧道终会凿穿千仞的高冈必被爬上当百花凋谢的日子
2015-07-09 21:54:31
416
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人