hdu5432 二分

Pyramid Split

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 104    Accepted Submission(s): 50


Problem Description
Xiao Ming is a citizen who's good at playing,he has lot's of gold cones which have square undersides,let's call them pyramids.

Anyone of them can be defined by the square's length and the height,called them width and height.

To easily understand,all the units are mile.Now Ming has n pyramids,there height and width are known,Xiao Ming wants to make them again to get two objects with the same volume.

Of course he won't simply melt his pyramids and distribute to two parts.He has a sword named "Tu Long" which can cut anything easily.

Now he put all pyramids on the ground (the usdersides close the ground)and cut a plane which is parallel with the water level by his sword ,call this plane cutting plane.

Our mission is to find a cutting plane that makes the sum of volume above the plane same as the below,and this plane is average cutting plane.Figure out the height of average cutting plane.
 

 

Input
First line: T, the number of testcases.(1T100)

Then T testcases follow.In each testcase print three lines :

The first line contains one integers n(1n10000), the number of operations.

The second line contains n integers A1,,An(1in,1Ai1000) represent the height of the ith pyramid.



The third line contains n integers B1,,Bn(1in,1Bi100) represent the width of the ith pyramid.
 

 

Output
For each testcase print a integer - **the height of average cutting plane**.

(the results take the integer part,like 15.8 you should output 15)
 

 

Sample Input
2
2
6 5
107
8
702 983 144 268 732 166 247 569
20 37 51 61 39 5 79 99
 

 

Sample Output
1
98
 
思路:设分割平面的高度为x,可以简单推出x以上的椎体的体积为:((B * B) / (A * A)) * (A - x)^3 * 1 / 3

  

二分一个高度h, 因为只需求整数部分,当(int)low == (int)high时,二分结束
posted @   JL_Zhou  阅读(188)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
点击右上角即可分享
微信分享提示