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.(≤T≤)

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

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

The second line contains n integers A1,…,An(≤i≤n,≤Ai≤) represent the height of the ith pyramid.

The third line contains n integers B1,…,Bn(≤i≤n,≤Bi≤) 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 )
 
Sample Input

 
Sample Output

 
Source
 
 #pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<stdlib.h>
using namespace std;
#define ll long long
#define eps 1e-10
#define MOD 1000000007
#define N 10006
#define inf 1e12
int n;
double h[N];
double w[N];
double q;
bool solve(double x){
double sum=;
for(int i=;i<n;i++){
double wh=h[i]-x;
if(wh>){
double p=wh/h[i];
double ww=p*w[i];
double ans=ww*ww*wh/3.0;
sum+=ans;
} }
if(sum>=q) return true;
return false;
}
int main()
{
int t;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%lf",&h[i]);
}
for(int i=;i<n;i++){
scanf("%lf",&w[i]);
}
q=;
for(int i=;i<n;i++){
q=q+w[i]*w[i]*h[i]/3.0;
}
q=q/2.0;
double low=;
double high=;
for(int i=;i<;i++){
double mid=(low+high)/;
if(solve(mid)){
low=mid;
}
else{
high=mid;
}
}
printf("%d\n",(int)low);
} return ;
}

hdu 5432 Pyramid Split(二分搜索)的更多相关文章

  1. hdu 5432 Pyramid Split 二分

    Pyramid Split Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contests/conte ...

  2. HDU 5432 Pyramid Split

    题意:有n个底面是正方形的四棱锥,用一个水平截面将所有四棱锥分成两半,要求上一半体积的和等于下一半,求水平截面的高度,输出整数部分. 解法:二分截面高度.比赛的时候二分写不明白了orz…… 代码: # ...

  3. HDU 5432 Rikka with Tree (BestCoder Round #53 (div.2))

    http://acm.hdu.edu.cn/showproblem.php?pid=5423 题目大意:给你一个树 判断这棵树是否是独特的 一颗树是独特的条件:不存在一颗和它本身不同但相似的树 两颗树 ...

  4. Trucking(HDU 2962 最短路+二分搜索)

    Trucking Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  5. hdu5432 Pyramid Split

    Problem Description Xiao Ming is a citizen who's good at playing,he has lot's of gold cones which ha ...

  6. hdu 5432

    Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...

  7. hdu5432 二分

    Pyramid Split Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  8. CVPR2021|一个高效的金字塔切分注意力模块PSA

    ​ 前言: 前面分享了一篇<继SE,CBAM后的一种新的注意力机制Coordinate Attention>,其出发点在于SE只引入了通道注意力,CBAM的空间注意力只考虑了局部区域的信息 ...

  9. hdu 2199 Can you solve this equation?(二分搜索)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

随机推荐

  1. class 类(3) 继承

    继承(Inheritance)是面向对象软 件技术当中的一个概念.如果一个类别A“继承自”另一个类别B,就把这个A称为“B的子类别”,而把B称为“A的父类别”,也可以称“B是A的超类”. 继承可以使得 ...

  2. Android: 在WebView中获取网页源码

    1. 使能javascript: ? 1 webView.getSettings().setJavaScriptEnabled(true); 2. 编写本地接口 ? 1 2 3 4 5 final c ...

  3. HDU 4588 Count The Carries 计算二进制进位总数

    点击打开链接 Count The Carries Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java ...

  4. 在Ubuntu上下载、编译和安装Android最新内核源代码(Linux Kernel)

    文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6564592 在前一篇文章提到,从源代码树下载下 ...

  5. 解决Fetching android sdk component information加载过久问题

    安装完成后,如果直接启动,Android Studio会去获取 android sdk 组件信息,这个过程相当慢,还经常加载失败,导致Android Studio启动不起开.解决办法就是不去获取and ...

  6. 让qq图标在自己的网站上显示方法

    代码如下: <div id="xixi" onmouseover="toBig()" style="top: 260px; left: 5px; ...

  7. puppet 4.4 System Requirements

    puppet是linux下自动部署管理工具,有apply,agent/server两种模式,安装后默认为agent/server模式. apply模式下,每台机器均有自己的catalog文件,如果需要 ...

  8. gitweb随记

    1.安装gitweb,命令安装即可 apt-get install gitweb 2.clone cgi $ git clone git://git.kernel.org/pub/scm/git/gi ...

  9. JSP 核心 (等待更新)

    开篇:JSP的等同于servlet 编译器将其转化为.class,后执行.一旦配置在Tomcat webapps,运行访问后,在Tomcat--->work文件内出现java文件,其内容即为转化 ...

  10. [Mugeda HTML5技术教程之12]制作跨屏互动应用

    mugeda动画平台还可以用来制作跨屏互动的动画应用,比如在PC端的大屏幕上显示动画的主界面,同时会显示出供手机扫描的二维码,手机扫描后会在手机上显示手机端动画界面.通过手机就可以和PC端的显示界面跨 ...