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;
}

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

最新文章

  1. MongoDB学习笔记五—查询上
  2. 2014年百度之星程序设计大赛 - 初赛(第二轮)JZP Set
  3. bzoj1150: [CTSC2007]数据备份Backup--贪心+优先队列维护堆
  4. [android] SQLite 数据库的升级 和 降级
  5. PHP中文URL编解码(urlencode()rawurlencode()
  6. Linux系统root用户忘记密码解决方法
  7. ToString函数用法
  8. Uva_10253 Series-Parallel Networks
  9. iOS原生CIFilter创建二维码
  10. .NET Framework 4.0 以上版本 下载地址
  11. Python 处理文件
  12. Android 自定义 View 圆形进度条总结
  13. Spring Dubbo 开发笔记
  14. Swing学习1——总体概述
  15. SpringCloud微服务基础
  16. Element-ui的表单中怎么添加正则校验
  17. 下载java生成PDF
  18. [py]编码-强力理解版
  19. 【新题】OCP 062题库出现很多新题-6
  20. 在动作类上加上SkipValidation 在反射时候会获取到该反射信息 就不会执行validate方法

热门文章

  1. Case When Exists SQL
  2. PHP MYSQLI中事务处理
  3. 如何批量转换 WordPress 文章分类
  4. js中关于prototype学习(2015年1月5号晚)
  5. 生日蛋糕 (codevs 1710) 题解
  6. Show or Hide Menu List via ng-show
  7. Keil的使用方法 - 常用功能(二)
  8. iOS反射机制
  9. i++与++i的误解
  10. 使用Linux调用资源库中的Job报错-ERROR: No repository provided, can&#39;t load job.