上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 31 下一页

2015年12月29日

spoj 375 QTREE - Query on a tree 树链剖分

摘要: 题目链接给一棵树, 每条边有权值, 两种操作, 一种是将一条边的权值改变, 一种是询问u到v路径上最大的边的权值。树链剖分模板。#include #include #include #include #include #include #include #include #include #incl... 阅读全文

posted @ 2015-12-29 00:20 yohaha 阅读(170) 评论(0) 推荐(0)

2015年12月28日

hihocoder #1260 : String Problem I

摘要: 题目链接时间限制:10000ms单点时限:1000ms内存限制:256MB描述我们有一个字符串集合S,其中有N个两两不同的字符串。还有M个询问,每个询问给出一个字符串w,求有多少S中的字符串可以由w添加恰好一个字母得到。字母可以添加在包括开头结尾在内的任意位置,比如在"abc"中添加"x",就可能得... 阅读全文

posted @ 2015-12-28 20:54 yohaha 阅读(286) 评论(0) 推荐(0)

codeforces 282E. Sausage Maximization Trie

摘要: 题目链接给n个数, 让你找出一个前缀和一个后缀, 它们异或完以后最大, 前缀和后缀都是异或得来的, 可以为空, 为空时按0算。前缀后缀不可覆盖。这题好神, 竟然是Trie树...首先将所有数的异或算出来作为初始的后缀, 初始前缀为0。 然后往字典树里插入前缀, 在对后缀进行查找, 查找时, 从高位往... 阅读全文

posted @ 2015-12-28 20:07 yohaha 阅读(344) 评论(0) 推荐(0)

UVA 10325 lottery 容斥原理

摘要: 题目链接给出m个数, 求1-n的范围内, 无法整除这m个数之中任何一个数的数的个数。设m个数为a[i], 对任意的i, n/a[i]是n中可以整除a[i]的数的个数, 但是这样对于有些数重复计算了, 那么就需要减去一些数, 对任意两个数, 设x为这两个数的lcm, 那么需要减去n/lcm,然后加上任... 阅读全文

posted @ 2015-12-28 16:55 yohaha 阅读(147) 评论(0) 推荐(0)

poj 2773 Happy 2006 容斥原理+二分

摘要: 题目链接容斥原理求第k个与n互质的数。#include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#de... 阅读全文

posted @ 2015-12-28 16:30 yohaha 阅读(148) 评论(0) 推荐(0)

POJ 1151Atlantis 扫描线+线段树求矩形面积并

摘要: 题目链接 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13... 阅读全文

posted @ 2015-12-28 09:56 yohaha 阅读(143) 评论(0) 推荐(0)

hdu 3333 Turing Tree

摘要: 题目链接给n个数, m个询问, 每次询问输出区间内的数的和, 相同的数只计算一次。数组里的数是>-1e9 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #i... 阅读全文

posted @ 2015-12-28 00:33 yohaha 阅读(153) 评论(0) 推荐(0)

2015年12月27日

codeforces 522D. Closest Equals 线段树+离线

摘要: 题目链接n个数m个询问, 每次询问输出给定区间中任意两个相同的数的最近距离。先将询问读进来, 然后按r从小到大排序, 将n个数按顺序插入, 并用map统计之前是否出现过, 如果出现过, 就更新线段树。如果当前的i等于某个询问的r, 那么就查询, 具体看代码。 1 #include 2 #inc... 阅读全文

posted @ 2015-12-27 15:39 yohaha 阅读(189) 评论(0) 推荐(0)

2015年12月26日

cdoj 1134 男神的约会 状压dp

摘要: 题目链接给一个10*10的方格, 每个格子里面有0-9,走到一个格子, 就要在这个格子待一段时间, 时间长度为这个格子的数字。 从左上角走到右下角, 要求0-9必须每种格子都要走到, 输出最短时间。在平常dp的基础上多开一维, 然后用二进制代表哪些走到过哪些没有走到过, 最后输出dp[10][10]... 阅读全文

posted @ 2015-12-26 16:18 yohaha 阅读(190) 评论(0) 推荐(0)

cdoj 1131 男神的礼物 区间dp

摘要: 题目链接给n个数字, 拿走两个数字a, b会有a*b的代价, 并新生成一个数字(a+b)%100, 求拿走所有数字所需的最小代价。区间dp, 枚举分界点, 然后记忆化搜索。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #... 阅读全文

posted @ 2015-12-26 15:42 yohaha 阅读(156) 评论(0) 推荐(0)

上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 31 下一页

导航