E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
K-th
2013 Multi-University Training Contest 5
k-th
point
刚开始我也不知道怎么做,后来慢慢就推出来了…… 对于样例 2 1 0,结果是2/3 2 2 0,结果是4/5 3 2 0,结果是6/7 3 2 1,结果是9/14=6/7*3/4 …… 之后就会发现每一项都是d/(d+1);而d又是怎样来的呢? 上面的d分别是2*1;2*2;3*2,3*1…… 所以规律就出来,哈哈…… 看代码: 1 #include
·
2015-11-08 15:26
test
Problem to be sovled
We say that the J-th disc and
K-th
disc intersect if J ≠ K and J-th
·
2015-11-08 14:37
em
POJ2104--
K-th
Number(主席树静态区间第k大)
[转载]一篇还算可以的文章,关于可持久化线段树 http://finaltheory.info/?p=249 无修改的区间第K大 我们先考虑简化的问题:我们要询问整个区间内的第K大。这样我们对值域建线段树,每个节点记录这个区间所包含的元素个数,建树和查询时的区间范围用递归参数传递,然后用二叉查找树的询问方式即可:即如果左边元素个数sum>=K,递归查找左子树第K大,否则递
·
2015-11-08 14:19
number
POJ 2104
K-th
Number (划分树 函数式线段树)
题目链接:http://poj.org/problem?id=2104 题意:给出一个数列,若干询问L,R,K,询问区间[L,R]之间的第K小的数。 思路:划分树,函数式线段树 //划分树 #include <iostream> #include <cstdio> #include <algorithm> using namespace
·
2015-11-08 11:10
number
POJ 2104
K-th
Number 划分树
Time Limit: 20000MS Memory Limit: 65536K Total Submissions: 29149 Accepted: 8799 Case Time Limit: 2000MS Description You are working for Macrohard company in data structures
·
2015-11-07 15:26
number
poj 2104
K-th
Number(可持久线段树)
K-th
Number 持久化:http://www.cnblogs.com/tedzhao/archive/2008/11/12/1332112.html 结构:http://www.docin.com
·
2015-11-07 15:10
number
POJ 2104
K-th
Number
POJ 2104
K-th
Number(划分树) 1 // 从源序列开始,首先
·
2015-11-05 08:31
number
poj 2104
K-th
Number
这题是给定你一个区间,求里面的第K大的数; 这里用到划分树: View Code #include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<cmath> #include<queue> #inc
·
2015-11-05 08:57
number
POJ2104
K-th
Number——划分树——pku2104
按照铎铎大牛的AC Record做的第一题,就被虐得很惨。 这是划分树的模板题。划分树,主要是求无更改的情况下区间第k小值。建树和线段树有些类似,但是划分树是在排序的基础上,左子树记录比中间值小的值,右子树记录比中间值大的数,在每棵子树中不改变原数列中的顺序。 查找也类似线段树,规定查找区间,定义函数Find(code,l,r,kth,dep),code为当前查找到的节点值,l,r是区间左右界
·
2015-11-02 17:36
number
pku 2104
K-th
Number && hdu 2665 Kth number 划分树
http://poj.org/problem?id=2104 http://acm.hdu.edu.cn/showproblem.php?pid=2665 题意: 给定一个长度为n的序列,求一个区间[L,R]内第K大的数; 思路: 划分树模板题。 给出个人感觉讲解比较好的连接: http://blog.sina.com.cn/s/blog_5f5353cc0100ki
·
2015-11-02 15:49
number
POJ 2104
K-th
Number
POJ_2104 上课之前大概看了一下划分树,后来上课的时候自己YY了一个“划分树”,结果发现每次查询复杂度不是logn的,大约是logn*logn的,写出来之后一交好像跟归并树的复杂度差不多,也就这个就是归并树吧…… 今天不早了,就先睡了,等明天起来之后再仔细研究一下划分树怎么写吧。 View Code #inc
·
2015-11-02 14:07
number
poj 2104
K-th
Number 划分树
poj 2104
K-th
Number //poj 2104
K-th
Number //划分树 //建树和查找,模板题,具体看代码 #define infile freopen(&
·
2015-11-02 09:15
number
poj 2104
K-th
Number (划分树)
http://poj.org/problem?id=2104 入门的划分树,说实话一开始看着挺晕的,真看明白了,知道了各个操作各个变量的意义就简单多了。 这个有没有线段树的解法?既然是基于线段树的,那么处理这种问题就应该比线段树的复杂度低很多吧。 code: #include <cstdlib> #include <cc
·
2015-10-31 15:09
number
SPOJ 3273 - Order statistic set , Treap
点击打开链接 题意: 集合S支持一下四种操作: INSERT(S,x) : 假设S中没有x,则插入x DELETE(S,x): 假设S中有x,则删除x
K-TH
·
2015-10-31 13:37
order
【原】 POJ 2104
K-th
Number 线段树 划分树 合并树 解题报告
http://poj.org/problem?id=2104 方法: 1、划分树,是平衡树:数组排序nlgn,建树nlgn,m次查询mlgn,总复杂度为O(nlgn+mlgn) 划分树就是利用类似线段树的树型结构记录划分元素(最终排序)的过程。 划分树是一种树形结构的二维数组,由
·
2015-10-31 11:38
number
POJ 2985 The
k-th
Largest Group
POJ_2985 这个题目以cats的个数为关键字建立线段树去做,我为了练一下昨天刚学的SBT所以就用SBT写了,不过SBT的效率要低一些。 #include<stdio.h>#include<string.h>#define MAXD 200010#define MAXM 400010int N, M, T, node, p[M
·
2015-10-31 11:49
group
树状数组从前往后求和,用来解第k大(或小)的数 poj 2985 The
k-th
Largest Group
来自http://www.cnblogs.com/oa414/archive/2011/07/21/2113234.html的启发, 看上述博客如何求第k大的数时,被其第二份代码影响,感觉很巧妙,于是研究了一下,搞懂后顿时神清气爽啊。。。 还是看这张经典的图吧,知识在图上就变得形象多了 现在假设要求sum[a]的值,一般我们都是从后往前求和,如
·
2015-10-31 08:10
group
微软2014实习生招聘笔试第2题 the
k-th
string
Time Limit: 10000msCase Time Limit: 1000msMemory Limit: 256MB Description Consider a string set that each of them consists of {0, 1} only. All strings in the set have the same number of 0s a
·
2015-10-30 14:59
String
Poj 2104区间第k大(归并树)
题目链接
K-th
Number Time Limit: 20000MS Memory Limit: 65536K Total Submissions
·
2015-10-30 14:29
poj
Careercup - Google面试题 - 6283958983589888
2014-05-06 11:31 题目链接 原题: Find the
k-th
Smallest Element in Two Sorted Arrays.
·
2015-10-30 13:04
Google
poj 2104
K-th
Number 主席树
K-th
Number Time Limit: 20000MS Memory Limit: 65536K Total Submissions: 39737
·
2015-10-30 13:58
number
Algorithm backup ---- Find the kth largest number(寻找第K大数)
Here is a way to find the
k-th
largest number from an ayyay based on the theory of quick sort with
·
2015-10-27 16:06
Algorithm
POJ2104
K-th
Number 主席树
题目链接:http://poj.org/problem?id=2104题目大意:求区间第k小的数。分析:主席树模板题。实现代码如下:#include #include #defineN100010 intT[N]; intnum[N]; intsan[N]; intls[N*20]; intrs[N*20]; intsum[N*20]; inttot,rt; intn,m; voidBuil
AC_Gibson
·
2015-10-23 08:00
poj 2104
K-th
Number(划分树)
题目链接:http://poj.org/problem?id=2104 题目分析:该问题给定一段区间中的值,再给定一段查询区间[ql, qr],需要给出该查询区间中的值在排序后的第K大的值; 使用划分树即可解决该问题;划分树的建树的复杂度为O(NlogN),查询一个区间的第K大值的复杂度为O(logN); 代码如下: #include <cstdio> #i
·
2015-10-21 13:38
number
转 经典的KNN算法解释
KNN全名是
k-th
nearest neighbor,中文意思是「第k位最接近的鄰居」。甚麼是「第k位最接近的鄰居」呢?假設在一個廣場上,有100個朋友,每位朋友都是你的鄰居,最接近你的鄰居,就
·
2015-10-21 11:40
算法
poj 2104
K-th
Number (主席树学习第一弹)
题目链接:poj2104题目大意:给出n个数,询问m次,每次询问在区间[l,r]里的第k大的树。题目分析:其实是可以直接划分树搞的,但是为了学习主席树,写了一发,发现代码量更少更简洁。首先将数字离散化,然后对数字进行建树,然后按照原顺序对主席树进行修改,也就是将数位对应到时序上,那么也就是每次将查询对应到就是查找时序在找到r时序的线段树和l时序的线段树的差,每次向下深入时,就是如果左子树的数的数目
qq_24451605
·
2015-10-10 22:00
主席树
可持续化线段树
区间第k大
【poj2104】
K-th
Number 归并树
说起来这是第二次A这个题了23333第一次是分块,戳这里归并树比分块打起来爽,速度还快,简直好评思想:线段树套数组【雾。线段树每个节点保存它所表示的区间的有序数字排列。实现就是在归并排序的过程中保存归并排序的过程。蛮好打的。并且调试什么的也没出什么大问题别忘了手动读入,别忘了读负数,归并排序的tmp数组不要menset(会T)(所以我直接没用tmp数组)代码:#include #include #
LOI_DQS
·
2015-10-10 08:00
线段树
poj
【poj2104】
K-th
Number 分块
DescriptionYouareworkingforMacrohardcompanyindatastructuresdepartment.Afterfailingyourprevioustaskaboutkeyinsertionyouwereaskedtowriteanewdatastructurethatwouldbeabletoreturnquicklyk-thorderstatistics
DQSSS
·
2015-09-19 21:39
代码能力
===数据结构===
二分
分块
===基础算法===
===其他算法===
【poj2104】
K-th
Number 分块
DescriptionYouareworkingforMacrohardcompanyindatastructuresdepartment.Afterfailingyourprevioustaskaboutkeyinsertionyouwereaskedtowriteanewdatastructurethatwouldbeabletoreturnquicklyk-thorderstatistics
LOI_DQS
·
2015-09-19 21:00
二分
分块
POJ 2104
K-th
Number 主席树 静态区间第K大
题目大意:就是给出一个静态的序列然后多次询问问某一连续的数中的第k大的数是多少,k也会变化大致思路:主席树学习第一题...这个函数式线段树的思路感觉好巧妙==对于给出的序列离散化之后对于离散化之后的值域建线段树,对于序列的每一个前缀都建立线段树,然后充分利用以前的版本,使得空间复杂度降到O(nlogn)的级别由于支持访问历史版本,可以利用减法来得到需要的区间[l,r]中的值在[L,R]中的数的个数
u013738743
·
2015-09-09 20:00
number
poj
主席树
K-th
2104
BZOJ 2104
K-th
Number
题目大意:求区间内第k小的数。解题思路:据说是主席树裸题,也可以用归并树划分树来搞。然而我这么弱怎么可能会呢……算了算复杂度和POJ的机器速度,YY了半天,写个模拟,卡时过了。#include structnode{ intid,x; }a[100000]; intcmp(voidconst*p,voidconst*q){ return(*(structnode*)p).x>(*(structn
qq919017553
·
2015-08-29 16:00
POJ 2104
K-th
Number
//这道题的意思是求给你一串数,叫你求第L个到第R个中第K大的数。纯暴力过得,理论上暴力需要60s,但这题就这样奇迹般的过了。线段树我暂时还没想到怎么做,暂时放放//AC代码:#include #include #include usingnamespacestd; structnode { intx,id; }t[1000005]; intcmp(nodep,nodeq) { returnp.x
zyx520ytt
·
2015-08-26 23:00
POJ 2104
K-th
Number(区间第k大数)(平方分割,归并树,划分树)
题目链接:http://poj.org/problem?id=2104解题思路:因为查询的个数m很大,朴素的求法无法在规定时间内求解。因此应该选用合理的方式维护数据来做到高效地查询。如果x是第k个数,那么一定有(1)在区间中不超过x的数不少于k个(2)在区间中小于x的数有不到k个因此,如果可以快速求出区间里不超过x的数的个数,就可以通过对x进行二分搜索来求出第k个数是多少。接下来,我们来看一下如何
piaocoder
·
2015-08-25 10:00
划分树
归并树
平方分割
[POJ2104]
K-th
Number/[POJ2761] Feed the dogs
K-thNumberTimeLimit:20000MSMemoryLimit:65536KDescriptionYouareworkingforMacrohardcompanyindatastructuresdepartment.Afterfailingyourprevioustaskaboutkeyinsertionyouwereaskedtowriteanewdatastructurethat
slongle_amazing
·
2015-08-15 16:00
Treap树(并查集 + 树堆)POJ —— 2985 The
k-th
Largest Group
对应POJ题目:点击打开链接Thek-thLargestGroupTimeLimit:2000MS MemoryLimit:131072KTotalSubmissions:7863 Accepted:2528DescriptionNewmanlikesplayingwithcats.Hepossesseslotsofcatsinhishome.Becausethenumberofcatsisrea
u013351484
·
2015-07-30 13:00
POJ 2104
K-th
Number
题意:给定一个数组,输入i,j,k,也就是询问i到j之间第k大的数思路:暴力,主席树(模板题);1、暴力就是对每一个数标好顺序,然后排序(这时候预处理完成);对于每个查询,暴力的扫一遍,遇到序号在i,j之间的数就k--,k=0是,就是所找的数/*暴力法 Time:7563MS */ #include #include #include usingnamespacestd; constintN=10
Mr_Xujh
·
2015-07-19 22:00
poj
主席树
Google Interview - Kth Smallest Element in BST
Given a binary search tree and an integer K, find
K-th
smallest element in BST.For example: Input
yuanhsh
·
2015-06-15 09:00
interview
Google Interview - Kth Smallest Element in BST
Given a binary search tree and an integer K, find
K-th
smallest element in BST.For example: Input
yuanhsh
·
2015-06-15 09:00
interview
poj2104
K-th
Number(主席树)
同一道题开两篇主席树:可用于查询:一个数列{a1,a2,…,an}在给定区间[L,R]内各元素(即所有a1,a2,…,an)的出现次数 这个数据结构由n棵形状相同的线段树构成,第i棵线段树记录:前缀区间[1,i]内各元素的出现次数 要先将a[]离散化,得到离散化后元素的范围1~m。而线段树的每个节点就对应其中一段子区间,节点值记录区间内所有元素出现次数之和 也就是说:线段树i上的子区间[i,j]之
cjk_cjk
·
2015-02-24 02:00
poj
主席树
poj2104
K-th
Number(划分树)
划分树模板题:给定1~n的一种排列,m次询问区间[i,j]中第k小的数 (1 #include structNode { intv[100005],num[100005];//T[i].v[j]:划分树第i层的第j个位置的权值,T[i].num[j]:划分树第i层的第left~j个位置有多少个进了下一层的左孩子 }; NodeT[20]; inta[100005]={0}; voidjh(int*
cjk_cjk
·
2015-02-21 02:00
poj
划分树
[LeetCode] Find the
k-th
Smallest Element in the Union of Two Sorted Arrays
Question:GiventwosortedarraysA,Bofsizemandnrespectively.Findthek-thsmallestelementintheunionofAandB.Youcanassumethattherearenoduplicateelements.http://leetcode.com/2011/01/find-k-th-smallest-element-i
furuijie8679
·
2015-01-19 06:25
LeetCode
Interview
[LeetCode] Find the
k-th
Smallest Element in the Union of Two Sorted Arrays
Question:GiventwosortedarraysA,Bofsizemandnrespectively.Findthek-thsmallestelementintheunionofAandB.Youcanassumethattherearenoduplicateelements.http://leetcode.com/2011/01/find-k-th-smallest-element-i
furuijie8679
·
2015-01-19 06:25
LeetCode
【POJ 2104】
K-th
Number
K-thNumberTimeLimit: 20000MS MemoryLimit: 65536KTotalSubmissions: 38927 Accepted: 12663CaseTimeLimit: 2000MSDescriptionYouareworkingforMacrohardcompanyindatastructuresdepartment.Afterfailingyourprevio
Regina8023
·
2014-12-13 18:00
数据结构
poj
OI
主席树
【POJ2104】
K-th
Number 主席树?函数式线段树?可持久化线段树?……反正是其中一个
题意:区间静态第K大。题解:可持久化线段树。可持久化线段树:基本思想:我们维护插入每个节点后的线段树。朴素写法(MLE+TLE)我们对于每次插入,都复制一棵线段树而后插入,这样保证了“可持久化”。但是显然,时间复杂度和空间复杂度都是n^2的。233。所以有了优化写法:我们发现每次的插入只有logn个节点被改变,所以只需要这些点新建,其它点都指向原来版本的节点就好了。空间复杂度nlogn。然后这道题
Vmurder
·
2014-12-12 08:00
number
poj2104
主席树
可持久化线段树
函数式线段树
K-th
在排序数组中找到第k个元素 find the
k-th
element in two sorted arrays
相关问题1:medianoftwosortedarray相关问题2:在排序数组中找到第k个元素findthek-thelementintwosortedarrays相关问题3:两个排序的数组,找到第k大的元素在排序数组中找到第k个元素findthek-thelementintwosortedarrays本题更简洁的算法:http://blog.csdn.net/jiyanfeng1/article
jiyanfeng1
·
2014-12-01 06:00
【BestCoder】 HDOJ 5102 The
K-th
Distance
按题解所说广搜就行。。。。#include #include #include #include #include #include #include #include #include #include #include #include #include #definemaxn200005 #definemaxm1000005 #defineeps1e-10 #definemod1000000
blankcqk
·
2014-11-09 10:00
HDU
【HDU】3943
K-th
Nya Number 数位DP
传送门:【HDU】3943K-thNyaNumber题目分析:数位DP预处理出每一个状态下数的个数,然后每次询问就递推一下。dp数组记录了之前是从哪个数字过来时可以比较方便的处理本题。这题代码应该是被我写复杂了==。代码如下:#include #include #include usingnamespacestd; typedeflonglongLL; #pragmacomment(linke
u013368721
·
2014-10-31 11:00
HDU
poj 2104
K-th
Number(线段树)
求区间第K大数。线段树每个区间维护一个有序的数组。然后求解时二分第K大的数是多少。假设是t再在线段树的每个区间里二分查询有多少小于等于t的,最后返回要查的区间里共有多少小于等于t的,如果小于K那么答案不可行,反之可行,每次查询是lognlogn的。在建树时对于merge操作,线段树的每一层刚好要遍历n个元素,共logn层,所以总的时间复杂度仍是nlogn的还是要学一下求第K大数正规做法:划分树代码
Baoli1008
·
2014-10-10 18:00
线段树
二分搜索
POJ 2104
K-th
Number 划分树
题目大意:给定一个序列,每次询问区间第k小BZOJ又维护。。。尼玛,题写完交不上去,各种虐心。。。。。只能去学学其它的数据结构了0.0静态序列求区间第k小,典型的划分树,具体写法直接见百度,这里不加累述#include #include #include #include #defineM100100 usingnamespacestd; intn,m,a[M],b[M],c[M]; ints[2
PoPoQQQ
·
2014-09-23 13:00
poj
poj2104
划分树
POJ 2104
K-th
Number
静态区间第K大,主席树写法。主席树第一题,如果对整段区间建线段树可以求1~n范围内的第K大,要想求任意区间内的第K大需要建1~i的n棵线段树。求某一段的时候区间相减就可以了。但是这样空间消耗太大所以要尽量利用以前的节点。注意到1~i的线段树和i~i+1的线段树只某一条链上的值不同,所以我们只要建出这一条链就可以了,剩下的节点和1~i+1的线段树是一样的,我们直接把节点指过去。T[...]记录以1~
u012797220
·
2014-07-28 12:00
上一页
1
2
3
4
5
6
7
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他