1075. Thread in a Space

Time limit: 1.0 second
Memory limit: 64 MB
There are three points in a 3-dimensional space: AB 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 AB 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
12 0 0
10 0 10
10
19.71
Problem Author: Alexander Mironenko 
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 ;
}

ural 1075. Thread in a Space的更多相关文章

  1. Ural Vol1(dif>=900)

    目前已AC:  2 1040.Airline Company(构造) 题目要求与每个顶点相连的所有边编号最大公约数为1,其实只要其中的两条边编号互质,所有边编号的最大公约数一定为1.我们知道相邻的数字 ...

  2. URAL 1707. Hypnotoad&#39;s Secret(树阵)

    URAL 1707. Hypnotoad's Secret space=1&num=1707" target="_blank" style="" ...

  3. Thread Costs

    https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Multithreading/CreatingTh ...

  4. PatentTips – GPU Saving and Restoring Thread Group Operating State

    BACKGROUND OF THE INVENTION The present invention relates generally to single-instruction, multiple- ...

  5. Difference between Process and thread?

    What are the differences between a process and a thread? How are they similar? How can 2 threads com ...

  6. karottc A Simple linux-virus Analysis、Linux Kernel <= 2.6.37 - Local Privilege Escalation、CVE-2010-4258、CVE-2010-3849、CVE-2010-3850

    catalog . 程序功能概述 . 感染文件 . 前置知识 . 获取ROOT权限: Linux Kernel <= - Local Privilege Escalation 1. 程序功能概述 ...

  7. MIT jos 6.828 Fall 2014 训练记录(lab 3)

    注:源代码参见我的github: https://github.com/YaoZengzeng/jos Part A : User Environments and Exception Handlin ...

  8. ltrace killed by SIGTRAP

    [Ltrace-devel] ltrace stucks with pthreads Heiko Carstens heiko.carstens at de.ibm.comFri Apr 14 11: ...

  9. EMC题2

    易安信笔试题分享:1 protected成员函数能被肿么调用2 “has-a” relationship是指的啥,答案有instance, reference, pointer等...3 int, c ...

随机推荐

  1. sql 查询最近30分钟或者自定义时间数据

    ) FROM dual; 30分钟或者自定义

  2. LeetCode : 287. Find the Duplicate Number

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAACRAAAAMMCAYAAAAhQhmZAAAMFGlDQ1BJQ0MgUHJvZmlsZQAASImVlw ...

  3. nfs 是Network File System 网络文件系统

    NFS的基本原刚是容许不同的客户端及服务通过一组PRC分享相同的文件系统,它是独立于操作系统,容许不同硬件及操作系统的系统共同进行文件的分享.NFS在文件传送过程中依赖于RPC协议.远程过程调用Rem ...

  4. SQL——触发器——插入触发器——边学边项目写的。

    需求: 项目表项目编码触发器编写 为项目表DwProject编写触发器,目的为当创建新项目时,且ProjectNo 为Null或空字符串时,自动创建项目编号,编号格式为4位年号,2位月份,2位顺序号, ...

  5. Android浏览本地 API文档 + 解决页面加载慢的问题

    火狐浏览器安装离线浏览插件: 用浏览器打开index.html文件,你会发现加载的很慢,原因你懂的,为此,我们可以通过离线的方式 查看本地API文档,用火狐浏览器  +   Work Offline插 ...

  6. css 妙味 总结

    技巧一: <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF- ...

  7. [Monitor] 监控规则定义

    系统监控规则:

  8. How to use the Visual Studio

    推荐一个提供VS配色方案的一个网站:StudioStyles,域名和网站同名:http://studiostyl.es/ 2. 整行剪切:Ctrl + X.光标不要选中任何文字,然后按这个快捷键就可以 ...

  9. 数据库ORM框架GreenDao

    常用的数据库: 1). Sql Server2). Access3). Oracle4). Sysbase5). MySql6). Informix7). FoxPro8). PostgreSQL9) ...

  10. android之SharedPreferes

    Android应用开发SharedPreferences存储数据的使用方法 SharedPreferences是Android中最容易理解的数据存储技术,实际上SharedPreferences处理的 ...