Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:用数组模拟二叉树,结点数肯定是2的一个幂||不用考虑y

Posted by baicaitest at 2009-08-12 22:44:06 on Problem 2352
In Reply To:用数组模拟二叉树,结点数肯定是2的一个幂,所以,向上靠拢 Posted by:userfriendly at 2009-03-22 16:43:44
> *3是用多了空间的,*2很可能是空间不足的
> 
> 要用N个结点,就要取  2^(log2(N)向上取整)这么个大小的数组,树根在数组下标0的话,左儿子在r*2+1, r*2+2,用惯了树根在1就+10安全第一 ~~~~~
32000+16000+8000+4000+2000+1000+500+250+125+63+32+16+8+4+2+1=64001?
1 3 7 15 31 63 127(31000)255(31500)511(31750)1023-31875 2047-31937 4095-31968 8191-31984.375 16383-31992.1 32767-31996.09 
程序里x坐标32000的星星用到的节点编号也是32767.应该没有比这个大的结点了吧?
*3的话是哪些地方用到了>32767编号的结点呢?
经过试验,测试数据里面没有超过32000的数据。
ps:Stars are listed in ascending order of Y coordinate. 
也就是说,不用考虑y了。这个开始很困扰我啊。。。

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator