1043 - Triangle Partitioning
Time Limit: 0.5 second(s) Memory Limit: 32 MB

See the picture below.

You are given ABAC and BCDE is parallel to BC. You are also given the area ratio between ADE and BDEC. You have to find the value of AD.

Input

Input starts with an integer T (≤ 25), denoting the number of test cases.

Each case begins with four real numbers denoting AB, AC, BC and the ratio of ADE and BDEC (ADE / BDEC). You can safely assume that the given triangle is a valid triangle with positive area.

Output

For each case of input you have to print the case number and AD. Errors less than 10-6 will be ignored.

Sample Input

Output for Sample Input

4

100 100 100 2

10 12 14 1

7 8 9 10

8.134 9.098 7.123 5.10

Case 1: 81.6496580

Case 2: 7.07106781

Case 3: 6.6742381247

Case 4: 7.437454786


PROBLEM SETTER: JANE ALAM JAN

题目大意很明显,求AD

思路:对AD二分  注意边和面积是平方的倍数关系(S=sqrt(p(p-a)(p-b)(p-c)) p=(a+b+c)/2 就能看出来了)

当然这题也可以找关系直接做出来

#include<stdio.h>
#include<math.h>
#define eps 1e-9
#define min(a,b) ((a)<(b)?(a):(b))
int main(){
int t;
double a,b,c,high,low,mid;
scanf("%d",&t); double kk;
// cout<<min(t,a);
for(int i=1;i<=t;i++){
scanf("%lf%lf%lf%lf",&a,&b,&c,&kk);
high=a;
low=0; while(high-low>eps){
mid=(high+low)/2;
if((mid/a)*(mid/a)>kk/(1+kk)) //找对关系式
high=mid;
else low=mid;
}
printf("Case %d: %.8lf\n",i,mid);
}
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

二分--1043 - Triangle Partitioning的更多相关文章

  1. 1043 - Triangle Partitioning(数学)

    1043 - Triangle Partitioning   PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit ...

  2. Lightoj 1043 - Triangle Partitioning【二分】

    题目链接:http://lightoj.com/volume_showproblem.php? problem=1043 题意:一个三角形ABC,DE//BC.已知三角形ADE和四边形BDEC的面积的 ...

  3. lightoj刷题日记

    提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...

  4. lightoj--1043-- Triangle Partitioning (水题)

    Triangle Partitioning Time Limit: 500MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu S ...

  5. [CF1019D]Large Triangle[极角排序+二分]

    题意 给出平面上 \(n\) 个点 \((x_i, y_i)\),问是否存在三个点构成的三角形的面积恰好为 \(S\) ,有的话,输出任意一组解即可. \(n\leq 2000\) 分析 BZOJ37 ...

  6. 【计算几何】【极角序】【二分】bzoj1914 [Usaco2010 OPen]Triangle Counting 数三角形

    极角排序后枚举每个点,计算其与原点连线的左侧的半平面内的点与其组成的三角形数(二分/尺取),这些都不是黄金三角形. 补集转化,用平面内所有三角形的个数(C(n,3))减去这些即可. 精度很宽松,几乎不 ...

  7. 【HDOJ6222】Heron and His Triangle(Java,二分,递推)

    题意:让你找这样的一个三角形,三条边为t,t-1,t+1,并且面积为整数,最后满足t大于等于n. n<=1e30 思路:直接推式子不会,打表找规律 f(n)=4*f(n-1)-f(n-2)(n& ...

  8. 2019 ACM-ICPC 南京 现场赛 K. Triangle (二分)

    题意 给定一个三角形和一个点 \(p\),如果该点不在三角形边上直接输出 \(-1\),否则在三角形上找一点 \(q\),使得线段 \(pq\) 平分三角形面积. 思路 看完题想都没想直接二分了. 就 ...

  9. JAVA源码走读(二)二分查找与Arrays类

    给数组赋值:通过fill方法. 对数组排序:通过sort方法,按升序.比较数组:通过equals方法比较数组中元素值是否相等.查找数组元素:通过binarySearch方法能对排序好的数组进行二分查找 ...

随机推荐

  1. Windows2003 IIS开启Gzip网页压缩

    1.单击"开始"-"管理工具"-"Internet 信息服务(IIS)管理器",打开IIS管理器:2.在 "IIS 管理器&quo ...

  2. 合并多个List<T>类型并通过LINQ按指定属性排序

    后台CS代码: namespace WebFormTest.TestCollect { public partial class ListTest : System.Web.UI.Page { pro ...

  3. 微软必应·英雄会第三届在线编程大赛:几个bing?

    发布公司:微软亚太研发集团 有 效 期:2013-12-31至2014-02-01 难 度 等 级: 答 题 时 长:120分钟 编程语言要求:C C++ Java C# 悬赏详情 一等奖 : 价值2 ...

  4. 删:[CentOS 7] 安装nginx

    下载对应当前系统版本的nginx包(package) # wget  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-cent ...

  5. C#使用SQL存储过程完整流程

    存储过程就是固化在SQL数据库系统内部的SQL语句,这样做的好处是可以提高执行效率.提高数据库的安全性.减少网络流量.接下来就讲解如何在数据库中建立一个存储过程. 打开SQL2055数据库,展开“数据 ...

  6. SHOW SLAVE STATUS几个常见参数

    --显示当前读取的Master节点二进制日志文件和文件位置,对应线程I/O thread Master_Log_File: mysql-bin.000011 Read_Master_Log_Pos: ...

  7. 共享内存shared pool (5):详解一条SQL在library cache中解析

    前面介绍的 shared pool,library cache结构,都是为了说明一条SQL是如何被解析的.先看下面的图: 图中涉及的各结构简单介绍 父HANDLE,里面有父游标堆0的地址.. 父游标堆 ...

  8. opengl基础学习专题 (二) 点直线和多边形

    题外话 随着学习的增长,越来越觉得自己很水.关于上一篇博文中推荐用一个 学习opengl的 基于VS2015的 simplec框架.存在 一些问题. 1.这个框架基于VS 的Debug 模式下,没有考 ...

  9. OpenStack: OVS安装

    > OVS安装:1. Install the Open vSwitch plug-in and its dependencies:# apt-get install \neutron-plugi ...

  10. [转]Not enough free disk space on disk '/boot'

    Not enough free disk space on disk '/boot' http://my.oschina.net/u/947673/blog/277224 # 解决 出现此情况是因为你 ...