ural 1075. Thread in a Space
2024-10-09 19:56:00
1075. Thread in a Space
Time limit: 1.0 second
Memory limit: 64 MB
Memory limit: 64 MB
There are three points in a 3-dimensional space: A, B and C. All the coordinates of the points are integer numbers with absolute values not greater than 1000. A solid ball with a center in the pointC is firmly fixed. A radius of the ball is R, a positive integer number. Distances from the point Cto the points A and B are strictly greater than R.
It is necessary to stretch a thread of minimal length between points A and B. Surely, the thread should be outside of the ball.
You are to find out a length of the thread.
Input
The first three lines contain coordinates of the points A, B and C respectively. The fourth one contains a radius R of the ball.
Output
should contain a minimal length of the thread to within 2 symbols after a decimal point. You should output answer with two or more digits.
Sample
input | output |
---|---|
0 0 12 |
19.71 |
Problem Author: Alexander Mironenko
Problem Source: Ural State Univerisity Personal Contest Online February'2001 Students Session
Problem Source: Ural State Univerisity Personal Contest Online February'2001 Students Session
Difficulty: 1029
题意:给出空间中三个整点。在一点的中央,固定了一个小球。小球的半径为R。其余两点在球外。 用最小长度的绳子连接剩下两点。求绳子的长度。
分析:因为只有三个点,所以可以放在平面上考虑。
如果连线不经过圆,显然可以直接求距离。
如果经过,那么有简单的平面几何知识即可。
而且处理时不需理会什么空间,直接用角度算即可。
/**
Create By yzx - stupidboy
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair inline int Getint()
{
int Ret = ;
char Ch = ' ';
bool Flag = ;
while(!(Ch >= '' && Ch <= ''))
{
if(Ch == '-') Flag ^= ;
Ch = getchar();
}
while(Ch >= '' && Ch <= '')
{
Ret = Ret * + Ch - '';
Ch = getchar();
}
return Flag ? -Ret : Ret;
} const DB EPS = 1e-;
struct Point
{
DB x, y, z;
inline void Read()
{
cin >> x >> y >> z;
}
} a, b, c;
DB r; inline void Input()
{
a.Read();
b.Read();
c.Read();
cin >> r;
} inline DB Sqr(DB x)
{
return x * x;
} inline DB Dist(Point a, Point b)
{
return sqrt(Sqr(a.x - b.x) + Sqr(a.y - b.y) + Sqr(a.z - b.z));
} inline void Solve()
{
DB ans = 0.0; DB ab = Dist(a, b),
ac = Dist(a, c),
bc = Dist(b, c); DB angle =
acos((Sqr(ac) + Sqr(bc) - Sqr(ab)) / (2.0 * ac * bc)) -
acos(r / ac) - acos(r/ bc);
if(angle <= EPS)
{
printf("%.2lf\n", ab);
return;
} ans += sqrt(Sqr(ac) - Sqr(r));
ans += sqrt(Sqr(bc) - Sqr(r));
ans += angle * r; printf("%.2lf\n", ans);
} int main()
{
freopen("g.in", "r", stdin);
Input();
Solve();
return ;
}
最新文章
- linux时间同步ntp服务的安装与配置
- Spring boot 基于Spring MVC的Web应用和REST服务开发
- 007商城项目:商品列表查询-需求分析,以及Spinmvc的访问知识
- Visual Studio版本号对应表
- ybutton 高端大气上档次华丽的按钮特效
- MapReduce的一点理解
- 打包Android:Error building Player: CommandInvokationFailure
- 在Unity3D 4中关联Visual Studio 2012来编写C#
- SQL 集合(笔记)
- Android开发技巧——去掉TextView中autolink的下划线
- Javascript&;Jquery获取浏览器和屏幕各种高度宽度方法总结及运用
- fragment嵌套,viewpager嵌套 不能正确显示
- python开发的一些tips
- sqlHelper的增删改查
- 【Socket编程】Java通信是这样炼成的
- Git的基本原理与常用命令[二]
- TOP100summit2017:网易云通信与视频CTO赵加雨:外力推动下系统架构的4个变化趋势
- vue项目遇到的坑
- andorid 进度条和图片的透明度
- web项目目录结构
热门文章
- 警告 - no rule to process file &#39;WRP_CollectionView/README.md&#39; of type net.daringfireball.markdown for architecture i386
- C++ STL string
- 按键的使用(一)------verilog
- centos vsftp 服务器配置
- 【转载】 Python 方法参数 * 和 **
- Unreal Engine4 学习笔记2 动画蒙太奇
- Jenkins搭建
- 使用PHPExcel导入Excel到MySql
- Spring之ResourceLoader加载资源
- VS2010 水晶报表的使用