二分--1043 - Triangle Partitioning
Time Limit: 0.5 second(s) | Memory Limit: 32 MB |
See the picture below.
You are given AB, AC and BC. DE 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 |
题目大意很明显,求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的更多相关文章
- 1043 - Triangle Partitioning(数学)
1043 - Triangle Partitioning PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit ...
- Lightoj 1043 - Triangle Partitioning【二分】
题目链接:http://lightoj.com/volume_showproblem.php? problem=1043 题意:一个三角形ABC,DE//BC.已知三角形ADE和四边形BDEC的面积的 ...
- lightoj刷题日记
提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...
- lightoj--1043-- Triangle Partitioning (水题)
Triangle Partitioning Time Limit: 500MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu S ...
- [CF1019D]Large Triangle[极角排序+二分]
题意 给出平面上 \(n\) 个点 \((x_i, y_i)\),问是否存在三个点构成的三角形的面积恰好为 \(S\) ,有的话,输出任意一组解即可. \(n\leq 2000\) 分析 BZOJ37 ...
- 【计算几何】【极角序】【二分】bzoj1914 [Usaco2010 OPen]Triangle Counting 数三角形
极角排序后枚举每个点,计算其与原点连线的左侧的半平面内的点与其组成的三角形数(二分/尺取),这些都不是黄金三角形. 补集转化,用平面内所有三角形的个数(C(n,3))减去这些即可. 精度很宽松,几乎不 ...
- 【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& ...
- 2019 ACM-ICPC 南京 现场赛 K. Triangle (二分)
题意 给定一个三角形和一个点 \(p\),如果该点不在三角形边上直接输出 \(-1\),否则在三角形上找一点 \(q\),使得线段 \(pq\) 平分三角形面积. 思路 看完题想都没想直接二分了. 就 ...
- JAVA源码走读(二)二分查找与Arrays类
给数组赋值:通过fill方法. 对数组排序:通过sort方法,按升序.比较数组:通过equals方法比较数组中元素值是否相等.查找数组元素:通过binarySearch方法能对排序好的数组进行二分查找 ...
随机推荐
- Win2008R2PHP5.4环境加载Zend模块
1.需要2个文件 Zend Optimizer和Zend Guard Loade s 下载Zend Guard Loader包.(官方地址:http://www.zend.com/en/product ...
- Winform主窗体的设置
软件必然涉及到一个主窗体MainForm,下面介绍一下几个简单的属性设置,可能比较有用 (1)icon,当然是咱们软件的图标了,设置上去即可 (2)isMdiContainer,这个比较重要了哦,必须 ...
- php的swoole扩展中onclose和onconnect接口不被调用的问题
在用swoole扩展写在线聊天例子的时候遇到一个问题,查了不少资料,现在记录于此. 通过看swoole_server的接口文档,回调注册接口on中倒是有明确的注释: * swoole_server-& ...
- C++ 里 构建动态二维数组
//****动态二维数组 /* int m=3; int **data; int n=2; data=new int*[m]; for(int j=0;j<m;j++) { data[j]=ne ...
- 刀哥多线程之并发队列gcd-05-dispatch_queue_concurrent
并发队列 特点 以先进先出的方式,并发调度队列中的任务执行 如果当前调度的任务是同步执行的,会等待任务执行完成后,再调度后续的任务 如果当前调度的任务是异步执行的,同时底层线程池有可用的线程资源,会再 ...
- VS2005内存泄漏检测方法[转载]
一.非MFC程序可以用以下方法检测内存泄露: 1. 程序开始包含如下定义: #ifdef _DEBUG #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __ ...
- Nunit单元测试的使用
先建立一个需要测试的项目 安装nunit 通过nuget安装Install-Package Nunit 类前加[TestFixture] 要测试的方法前加[Test] using System; u ...
- [原创]pg_shard使用场景及功能测试
pg_shard是一个PostgreSQL的sharding extension.可以用于Shards.Replicates tables和高可用.它可以在不修改Applications的情况下无缝分 ...
- hdu 2645 find the nearest station
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2645 find the nearest station Description Since dande ...
- zoj 2334 Monkey King/左偏树+并查集
原题链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1389 大致题意:N只相互不认识的猴子(每只猴子有一个战斗力值) 两只 ...