二分--1043 - Triangle Partitioning
来源:互联网 发布:window10和mac对比 编辑:程序博客网 时间:2024/05/19 20:47
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
- Lightoj 1043 Triangle Partitioning | 二分
- Lightoj 1043 - Triangle Partitioning【二分】
- LightOJ 1043 Triangle Partitioning
- LightOJ 1043 - Triangle Partitioning
- LIGHTOJ-1043 -Triangle Partitioning
- lightoj 1043 - Triangle Partitioning
- 【Light】[1043]Triangle Partitioning
- LightOJ 1043 - Triangle Partitioning
- Lightoj 1043 (Triangle Partitioning)
- LightOJ 1043 Triangle Partitioning
- 【LightOJ 1043 Triangle Partitioning】
- light oj 1043 Triangle Partitioning
- LightOJ 1043 - Triangle Partitioning【数学】
- lightoj 1043 - Triangle Partitioning 【水题】
- lightoj 1043 - Triangle Partitioning 公式
- lightoj 1043 - Triangle Partitioning (数学)
- LightOJ 1043Triangle Partitioning(数学)
- 连接Oracle数据库,VS2010中运行正常,发布到IIS上面报错
- HTML初学----块、布局
- 7.PHP内核探索:再次探讨SAPI
- 使用Dom4j解析XML
- LNMP环境下的nginx重写
- 二分--1043 - Triangle Partitioning
- split
- DM重要资源网址
- Ubuntu 14.04 iNode Client找不到库libjpeg和libtiff的解决方法
- sysfs
- nginx打包rpm
- 一窥朝鲜的计算机技术发展,操作系统,平板,杀毒软件,都有!
- xen网桥模式详解
- 今日小记,inline-block,absolute,