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(数学)的更多相关文章
- 二分--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的面积的 ...
- BNU27932——Triangle——————【数学计算面积】
Triangle Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO format: %lld Java class nam ...
- Kattis - triangle 【数学】
题意 求第N个迭代三角形 中 所有黑色三角形的周长的整数部分的位数 思路 该三角形的周长是 3^(n + 1)/ 2 ^ (n) 然后 可以用 long double 存下来 再求位数 就可以 AC ...
- 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 ...
- LaTeX 各种命令,符号
函数.符号及特殊字符 声调 语法 效果 语法 效果 语法 效果 \bar{x} \acute{\eta} \check{\alpha} \grave{\eta} \breve{a} \ddot{y} ...
- acdream.A Very Easy Triangle Counting Game(数学推导)
A - A Very Easy Triangle Counting Game Time Limit:1000MS Memory Limit:64000KB 64bit IO Forma ...
- HDU 5914 Triangle 数学找规律
Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...
随机推荐
- 小测试 php代理,nginx代理,直接访问对比
#php proxy total sent request num: 507 total handle read times: 506 506 fetches, 2 max parallel, 2.7 ...
- m文件转换为C/C++文件的编译、绘图、参数、打包问题总结
在工程计算相关项目中,常常利用Matlab来完成计算.算法.绘图等功能.使用Matlab来完成这些功能非常简单,Matlab提供的m编程语言功能强大,代码量少.为了在自己的C/C++项目中加入这些功能 ...
- HDU 3507 Print Article(CDQ分治+分治DP)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=3507 [题目大意] 将长度为n的数列分段,最小化每段和的平方和. [题解] 根据题目很容易得到dp ...
- python 在 for i in range() 块中改变 i 的值的效果
先上一段代码: for i in range(3): i = 2 print(i) 实际结果是: 2 2 2 可以发现实际效果就是 在每次执行 for 语句块的内容后 i 会被重新赋值
- c++11新特性(4) lambda捕捉块
lambda表达式中的方括号成为捕捉块,能够在这里指定怎样从所在的作用域中捕捉变量. 捕捉的意思是指能够在该lambda中使用该变量.即能够捕获外部变量在lambda表达式内使用. 能够使用两种方式来 ...
- iOS开发-Protocol协议及委托代理(Delegate)传值
前言:因为Object-C是不支持多继承的,所以很多时候都是用Protocol(协议)来代替.Protocol(协议)只能定义公用的一套接口,但不能提供具体的实现方法.也就是说,它只告诉你要做什么,但 ...
- 读取excel出现空值
表格里某列假如混杂了数字和字符就会有可能部分读取为空,连接Excel方法如下 string strConn = 'Provider=Microsoft.Jet.OLEDB.4.0;' 'Data So ...
- Lable 控件 -- 用代码改变要显示字体的颜色
lable控件怎么改变显示字体的颜色 代码如下: string color = "#B72C34"; this.lbl.ForeColor = System.Drawing.Col ...
- 关于MATLAB中any和all的个人理解
any: any=1,有一个元素是1,即可: any=0,全部元素为0,即可. all: all=1,全部元素是1,即可: all=0,有一个元素是0,即可. ALL True if all elem ...
- 寻找数列中第k大的数算法分析
问题描述:给定一系列数{a1,a2,...,an},这些数无序的,现在求第k大的数. 看到这个问题,首先想到的是先排序,然后直接输出第k大的数,于是得到啦基于排序的算法 算法一: #include&l ...