【Light-oj】-1043 - Triangle Partitioning(数学)
2016-08-23 21:45
495 查看
1043 - Triangle Partitioning
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.
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.
题意:知道三条边,面积比求AD的长。
题解:根据相似三角形性质就ok啦!
AC代码:
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define CLR(a,b) memset(a,b,sizeof(a))
int main()
{
int u,ca=1;
scanf("%d",&u);
while(u--)
{
double a,b,c,k;
scanf("%lf%lf%lf%lf",&a,&b,&c,&k);
k=k/(k+1);
k=sqrt(k);
printf("Case %d: %.8lf\n",ca++,k*a);
}
return 0;
}
PDF (English) | Statistics | Forum |
Time Limit: 0.5 second(s) | Memory Limit: 32 MB |
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的长。
题解:根据相似三角形性质就ok啦!
AC代码:
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define CLR(a,b) memset(a,b,sizeof(a))
int main()
{
int u,ca=1;
scanf("%d",&u);
while(u--)
{
double a,b,c,k;
scanf("%lf%lf%lf%lf",&a,&b,&c,&k);
k=k/(k+1);
k=sqrt(k);
printf("Case %d: %.8lf\n",ca++,k*a);
}
return 0;
}
相关文章推荐
- maven
- 【LightOJ 1045 Digits of Factorial】
- day12总结
- Opencv Mat矩阵中data、size、depth、elemSize、step等属性的理解
- python 学习(十五)之 字典
- Spring AOP 实践(四)利用annotation实现声明式服务
- 暑假练习赛 007 A - Time
- MySQL 5.6.22 win32 zip版安装
- 不得不在脑海里徘徊的站外(第三方)SEO优化策略
- 字典树
- mysql中日期类型DATETIME和TIMESTAMP的区别
- Light-oj-1045 lightoj1045 - Digits of Factorial (N!不同进制的位数)
- URAL 2062 Ambitious Experiment(树状数组)
- Spring 事物机制总结
- 查询每个部门中薪资最高的员工
- ELK 日志归集
- 计算机视觉、模式识别、机器学习相关方向资源
- Java基础之(三十六)Java异常处理<二>
- Node.Js 全局对象与全局属性(一)
- 后台执行Jquery代码