上一页 1 ··· 32 33 34 35 36 37 38 39 40 ··· 57 下一页

2016年12月12日

D. Alyona and a tree 公式转换 + 分块暴力

摘要: http://codeforces.com/problemset/problem/740/D 对于每一对<u, v>。设dis[u]表示root到点u的距离,那么dis<u去v>就是dis[v] - dis[u], 就是在它的儿子中找出有多少个v使得dis[v] - dis[u] <= a[v]。然 阅读全文

posted @ 2016-12-12 21:59 stupid_one 阅读(259) 评论(0) 推荐(0) 编辑

L 裁纸片 贪心 + 模拟

摘要: https://biancheng.love/contest-ng/index.html#/123/problems 如果只是输出最小的值,那么好办,a升序,b降序,这样是最优的。 但是需要次数,这就麻烦了。 但是注意到它说数字互不相同。 那么,用个数组book[a[i]]表示a[i]需要匹配的是那 阅读全文

posted @ 2016-12-12 11:06 stupid_one 阅读(166) 评论(0) 推荐(0) 编辑

POJ 2002 Squares 数学 + 必须hash

摘要: http://poj.org/problem?id=2002 只能说hash比二分快很多。随便一个hash函数都可以完爆二分。 判断是否存在正方形思路如下: 1、枚举任意两个点,作为正方形的一条边,那么,整个正方形就确定了,有两个方向。 因为, 设枚举的坐标为(x1, y1) & (x2, y2), 阅读全文

posted @ 2016-12-12 09:08 stupid_one 阅读(227) 评论(0) 推荐(0) 编辑

F 点与多边形 数学 + 观察

摘要: https://biancheng.love/contest-ng/index.html#/123/problems 做题要在纸上弄弄,才会有发现。 发现到答案只是-1和4,因为坐标都是整数。 然后就是找是否存在正方形了。 判断如下: 1、枚举任意两个点,作为正方形的一条边,那么,整个正方形就确定了 阅读全文

posted @ 2016-12-12 00:29 stupid_one 阅读(182) 评论(0) 推荐(0) 编辑

2016年12月11日

Coprime Conundrum 容斥原理

摘要: https://www.hackerrank.com/contests/hourrank-13/challenges/arthur-and-coprimes 我们可以枚举每一个p在[2, sqrt(n)]里,然后就是在[p + 1, n / p]中找有多少个数和p互质了。 标准容斥,先算出[1, n 阅读全文

posted @ 2016-12-11 10:49 stupid_one 阅读(262) 评论(1) 推荐(0) 编辑

2016年12月10日

hdu 1695 GCD 欧拉函数 + 容斥

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1695 要求[L1, R1]和[L2, R2]中GCD是K的个数。那么只需要求[L1, R1 / K] 和 [L2, R2 / K]中GCD是1的对数。 由于(1, 2)和(2, 1)是同一对。 那么我们枚举大区间 阅读全文

posted @ 2016-12-10 23:43 stupid_one 阅读(209) 评论(0) 推荐(0) 编辑

E. Xenia and Tree 分块 + LCA

摘要: http://codeforces.com/contest/342/problem/E 如果把询问1存起来,每到sqrt(m)的时候再处理一次。 那么总复杂度就是msqrt(m)的。 把要变颜色的节点存起来,可以同时一次O(n)的bfs 然后就是LCA了。LCA需要倍增的做法。这题真的是个好题。。 阅读全文

posted @ 2016-12-10 16:02 stupid_one 阅读(286) 评论(0) 推荐(0) 编辑

二分图匹配 + 构造 E. Arpa’s overnight party and Mehrdad’s silent entering

摘要: http://codeforces.com/contest/742/problem/E 跪着看题解后才会的。 对于任何一对BF[i]和GF[i] 连接了一条边后,那么他们和隔壁都是不会有边相连的了,这是题目数据保证的。因为BF[i]和GF[i]是唯一确定的嘛。 那么,我们把BF[i]连接去GF[i] 阅读全文

posted @ 2016-12-10 10:10 stupid_one 阅读(319) 评论(0) 推荐(0) 编辑

2016年12月9日

CF 602 D. Lipshitz Sequence 数学 + 单调栈 + 优化

摘要: http://codeforces.com/contest/602/problem/D 这题需要注意到的是,对于三个点(x1, y1)和(x2, y2)和(x3, y3)。如果要算出区间[1, 3]的L(h)函数的最大值,则一定不会是 通过(y3 - y1) / (x3 - x1)算出。因为很简单, 阅读全文

posted @ 2016-12-09 23:25 stupid_one 阅读(239) 评论(0) 推荐(0) 编辑

Problem 2238 Daxia & Wzc's problem 1627 瞬间移动

摘要: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1627 http://acm.fzu.edu.cn/problem.php?pid=2238 对应的51NOD这个题,先把n--和没m-- 再套公式 #include <cs 阅读全文

posted @ 2016-12-09 13:48 stupid_one 阅读(180) 评论(0) 推荐(0) 编辑

上一页 1 ··· 32 33 34 35 36 37 38 39 40 ··· 57 下一页

导航