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

题解:注意面积比是变长比的平方,另外p+1代表s/s2;s代表总面积,s2代表下面的四边形面积

代码:

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define PI(x) printf("%d",x)
#define PL(x) printf("%lld",x)
#define P_ printf(" ")
#define T_T while(T--)
typedef long long LL;
const int INF=0x3f3f3f3f; int main(){
int kase=0;
double a,b,c,p;
double d,area,ans;
int T;
SI(T);
T_T{
scanf("%lf%lf%lf%lf",&a,&b,&c,&p);
double k=p+1.0;
p=sqrt(1.0-1/k);
printf("Case %d: %lf\n",++kase,a*p);
}
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. BNU27932——Triangle——————【数学计算面积】

    Triangle Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO format: %lld      Java class nam ...

  4. Kattis - triangle 【数学】

    题意 求第N个迭代三角形 中 所有黑色三角形的周长的整数部分的位数 思路 该三角形的周长是 3^(n + 1)/ 2 ^ (n) 然后 可以用 long double 存下来 再求位数 就可以 AC ...

  5. lightoj刷题日记

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

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

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

  7. LaTeX 各种命令,符号

    函数.符号及特殊字符 声调 语法 效果 语法 效果 语法 效果 \bar{x} \acute{\eta} \check{\alpha} \grave{\eta} \breve{a} \ddot{y} ...

  8. acdream.A Very Easy Triangle Counting Game(数学推导)

    A - A Very Easy Triangle Counting Game Time Limit:1000MS     Memory Limit:64000KB     64bit IO Forma ...

  9. HDU 5914 Triangle 数学找规律

    Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...

随机推荐

  1. SGU 310. Hippopotamus( 状压dp )

    题目大意:给N块板, 有A,B2种类型的板, 要求任意M块连续的板中至少有K块B板.1≤n≤60,1≤m≤15,0≤k≤m≤n. dp(x, s)表示第x块板, x前M块板的状态为s, 然后合法状态转 ...

  2. bzoj 2141 : 排队 分块

    题目链接 2141: 排队 Time Limit: 4 Sec  Memory Limit: 259 MBSubmit: 1169  Solved: 465[Submit][Status][Discu ...

  3. MySQL my.cnf 参数说明

    MySQL 5.5.13 参数说明: [client] character-set-server = utf8 port    = 3306 socket  = /data/mysql/3306/my ...

  4. SSD的基本架构

    在SSD的优势一章中,我们对比过HDD和SSD的内部区别.现在,我们再谈一下SSD的基本架构.                   上图为一款典型的SSD架构图解,各部分的解释如下:       操作 ...

  5. 关于Struts2的碎碎念

    一:安全,还是安全 我入行比较晚,那会Spring MVC什么的都很流行了,一直觉得struts2作为一个Web MVC框架实在太笨重了点.所以虽然之前一直在用,但是其实没有真正研究过. 今天公司又遇 ...

  6. Windows Azure 上 Linux VM 中的交换空间 – 第 2 部分

    本文章由 Azure CAT 团队的 Piyush Ranjan (MSFT) 撰写. 在前一篇文章 Windows Azure 上Linux VM 中的交换空间第 1 部分中,我介绍了在默认情况下, ...

  7. Codeforces 427D Match &amp; Catch(后缀自动机)

    [题目链接] http://codeforces.com/problemset/problem/427/D [题目大意] 给出一个两个字符串,求出最短且在两个字符串中唯一的公共子串. [题解] 以原字 ...

  8. linux c 通过文件描写叙述符获取文件名称

    在linux中每一个被打开的文件都会在/proc/self/fd/文件夹中有记录,当中(/proc/self/fd/文件描写叙述符号:这个文件是符号文件)的文件就是文件描写叙述符所相应的文件. 而re ...

  9. Android仿人人客户端(v5.7.1)——个人主页(三)

    转载请标明出处:http://blog.csdn.net/android_ls/article/details/9405089 声明:仿人人项目,所用所有图片资源都来源于其它Android移动应用,编 ...

  10. css版hover现边框

    需要注意的是  hover中要给盒子加:position:relative; <style type="text/css"> *{margin:0;padding:0; ...