URAL 1294. Mars Satellites(余弦定理 数学啊 )
来源:互联网 发布:熟shou 知乎 编辑:程序博客网 时间:2024/05/16 00:57
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1294
1294. Mars Satellites
Time limit: 1.0 second
Memory limit: 64 MB
Memory limit: 64 MB
Four artificial satellites travel in one plane along the areostationary orbit around Mars. They have code names A, B, C and D and travel exactly in this order. Venus’s scouts for military purposes (for what particular purpose they did not say) decided to find a distance between satellites C and D. All Mars satellites could measure distances to the other satellites, that is why all what is needed to do is to penetrate in the computer system of satellite C and measure the distance to satellite D (or vice versa). Nevertheless, Martians are not so stupid and have not very bad defense. That is why all what could Venus’s scouts do is to break the defense of satellites A and B (that were older models). They measured distances from satellites A and B to satellites C and D, but now they do not know how to find the distance from C to D using these measurements. You can help them.
Input
There are 4 numbers: distances from A to D, from A to C, from B to D and from B to C in thousands kilometers (integers from 1 to 10000). Satellites can measure distance even through the planet and you may assume that orbit is a circle. Do not assume the radius of the orbit equal to 20392 km as it should be for the real areostationary orbit.
Output
If it is impossible to find out the distance from C to D with these data, you should print "Impossible.", otherwise you are to print "Distance is X km.", where X is the required distance in kilometers (rounded to the integer number).
Sample
4 7 5 7
Distance is 5385 km.
题意:
在一个圆上有有固定顺序的四点,告诉你AD AC BD BC的距离,求 CD的距离!
PS:
//同圆中相等弦所对的圆心角相等
代码如下:
#include <cstdio>#include <cmath>//同圆中相等弦所对的圆心角相等int main(){ int ad, ac, bd, bc; while(~scanf("%d%d%d%d",&ad,&ac,&bd,&bc)) { if(ad*ac == bd*bc)//分母相等,相减为零 { printf("Impossible.\n"); continue; } //余弦定理化简得: double t1 = (ad*ad+ac*ac)*2.0*bd*bc-(bd*bd+bc*bc)*2.0*ad*ac; double t2 = 2*bd*bc-2*ad*ac; double tt = t1*1.0/t2; if(tt < 0) { printf("Impossible.\n"); } else { tt = sqrt(tt); printf("Distance is %.0lf km.\n",tt*1000); } } return 0;}
1 0
- URAL 1294. Mars Satellites(余弦定理 数学啊 )
- URAL 1294. Mars Satellites
- 【数学】 URAL 1294 Mars Satellites
- timus 1294. Mars Satellites 余弦定理的应用
- URAL 1294. Mars Satellites 几何
- URAL 1294 Mars Satellites(圆内接三角形)
- Timus 1294 Mars Satellites
- 数学之美 系列十二 - 余弦定理和新闻的分类(转载)
- 数学之美(系列 12) 之 余弦定理和新闻的分类
- 余弦定理
- 数学之美:GOOGLE新闻归类算法与余弦定理
- 数学之美之余弦定理与新闻分类
- URAL 1515. Cashmaster (数学啊 )
- URAL 1885. Passenger Comfort(数学啊 )
- URAL 1889. Airport Announcements(数学啊 )
- URAL 1718 . Rejudge(数学啊 )
- URAL 1711. Code Names (数学啊 )
- URAL 1984. Dummy Guy(数学啊)
- [Leetcode]Jump Game II
- Android深入浅出之Binder机制
- LeetCode-Climbing Stairs
- poj 1741(1987) 树分治(求距离小于某值的点对数)
- u-boot烧写
- URAL 1294. Mars Satellites(余弦定理 数学啊 )
- LDA & PCA
- 自考路之C++大作战(上)
- HttpServletRequest
- 正则表达式中的 .*? 或 .*+ 是什么意思?
- Animation
- Win8.1无法安装msi软件提示2502、2503错误怎么解决?
- 多态总结
- KMP算法/字符串匹配算法