sgu 151 Construct a triangle
来源:互联网 发布:中国上古史知乎 编辑:程序博客网 时间:2024/06/05 12:04
题目描述:
151. Construct a triangle
time limit per test: 0.5 sec.
memory limit per test: 4096 KB
memory limit per test: 4096 KB
input: standard input
output: standard output
output: standard output
Find coordinates of any triangle ABC if it is know that |AB|=c, |AC|=b, |AM|=m, AM is a median of triangle.
Input
There are three real numbers in input: c, b, m (0<c,b,m<=10^3) separated by a space. Length of the fractional part of each number is not greater than 2 digits.
Output
If solution exists, write three lines. Write coordinates of point A to first line, coordinates of B to second line and coordinates of C to third line. Separate numbers by a space; absolute value of each coordinate must not exceed 10^4. Write numbers with 5 digits after decimal point. If there is no solution, write "Mission impossible"
Sample test(s)
Input
5 5 3
Output
0.00000 3.00000
-4.00000 0.00000
4.00000 0.00000
-4.00000 0.00000
4.00000 0.00000
把一个点放在原点 ,一个点放在(c,0) 点
那么中线长度就是
sqrt( c^2 + b^2 + 2 *cos( sita ) * b * c ) = m;
可以求出 sita ;
一切就ok了。
注意此题的三角形比较奇葩,可以是面积为0 的,也就是可以共线 。
贴代码:
#include<iostream>#include<cstring>#include<cstdio>#include<set>#include<algorithm>#include<vector>#include<cstdlib>#include<cmath>#define inf 0xfffffff#define CLR(a,b) memset((a),(b),sizeof((a)))#define FOR(a,b) for(int a=1;a<=(b);(a)++)using namespace std;int const nMax = 1010;int const base = 10;typedef int LL;typedef pair<LL,LL> pij;// std::ios::sync_with_stdio(false);double const eps = 1e-9;double const pi = acos(-1.0);double a,b,c,aa,ab;double he,ta;double F(double d){ return (aa+ab*cos(d))/4.0;}int main(){ scanf("%lf%lf%lf",&a,&b,&c); aa=a*a+b*b; ab=a*b*2.0; c*=c; double s=(4.0*c-aa)/ab; if(fabs(s)>1){ puts("Mission impossible"); return 0; } he=acos(s); printf("%.5lf %.5lf\n",0.0,0.0); printf("%.5lf %.5lf\n",a,0.0); printf("%.5lf %.5lf\n",b*cos(he),b*sin(he)); return 0;}
- sgu 151 Construct a triangle
- SGU 151 - Construct a triangle
- SGU 151 Construct a triangle(数学)
- sgu151 Construct a triangle
- sgu151:Construct a triangle
- sgu151: Construct a triangle
- SGU 299 Triangle(大数)
- A. Triangle
- A. Triangle
- Construct a Matrix FZU
- [SGU]100. A+B
- SGU 100. A+B
- SGU a^b-b^a
- foj 1911 Construct a Matrix
- How to construct a DiamondOfNumbers
- FZU 1911 Construct a Matrix
- FZU 1911Construct a Matrix
- Rendering a triangle
- synchronized和LOCK的实现---Java之锁研究
- HDU 4390 Number Sequence(容斥原理)
- 理解矩阵
- 一年没在这机子上写android程序,竟然签名过期了。
- 详解 EXPORT DISPLAY
- sgu 151 Construct a triangle
- 虚拟机上网
- ios5CookBook学习笔记之异步加载网络图片
- oracle jdk 安装
- Linux下.ko, .o, .so, .a, .la文件
- PHP图片验证码的实现-包括前后台页面
- SQL语句3——触发器
- How to be a good programmer
- 如何强制ffmpeg编码时输出一个关键帧