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. C/C++基础概念

    1.类占用的内存大小: 1)在不同位数的操作系统下,各种数据类型所占用的内存大小:32位和64位操作系统 http://blog.csdn.net/b_zhang/article/details/68 ...

  2. NetAnalyzer笔记 之 六 用C#打造自己的网络连接进程查看器(为进程抓包做准备)

    [创建时间:2016-04-13 22:37:00] NetAnalyzer下载地址 起因 最近因为NetAnalyzer2016的发布,好多人都提出是否可以在NetAnalyzer中加入一个基于进程 ...

  3. js中indexof()简单使用

    indexOf()方法返回某个指定的字符串值在字符串中首次出现的位置. stringObject.indexOf(searchvalue,fromindex):indexOf()方法对大小写敏感如果要 ...

  4. 一张图搞懂 Javascript 中的原型链、prototype、__proto__的关系 转载加自己的总结

    1. JavaScript内置对象 所谓的内置对象 指的是:JavaScript本身就自己有的对象 可以直接拿来就用.例如Array String 等等.JavaScript一共有12内置对象    ...

  5. [转]iOS hybrid App 的实现原理及性能监测

    转自:http://www.cocoachina.com/ios/20151118/14270.html iOS hybrid App 的实现原理及性能监测 2015-11-18 11:39 编辑:  ...

  6. 使用kindeditor 注意

    ValidateRequest="false"引用编辑器要在最上端加入上面的话

  7. AndroidAnnotations框架配置

    如今Android Studio的普及,Android开发基本要舍弃Eclipse了,最近使用AndroidAnnotations 注解框架的时候,找了些资料慢慢整出来了,在这给大家简单分享一下: 首 ...

  8. winscp连接vmware ubuntu

    winscp连接vmware ubuntu,因为第一次安装在虚拟机上的ubuntu是没有ssh服务的,不能在windows上通过工具进行连接,所以需要以下步骤进行ssh配置     1:检查ssh状态 ...

  9. zeromq源码分析笔记之线程间收发命令(2)

    在zeromq源码分析笔记之架构说到了zmq的整体架构,可以看到线程间通信包括两类,一类是用于收发命令,告知对象该调用什么方法去做什么事情,命令的结构由command_t结构体确定:另一类是socke ...

  10. PCL编译历程

    boost 编译安装包下载地址: http://boost.teeks99.com/ boost安装:http://blog.sina.com.cn/s/blog_7c48b0f10102v0zj.h ...