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. VAssistX的VA Snippet Editor的类注释和函数注释

    title:类注释shortcut:=== /******************************************************** [DateTime]:$YEAR$.$M ...

  2. iOS 百度地图坐标标注

    注:由于iOS9改用更安全的https,为了能够在iOS9中正常使用地图SDK,请在"Info.plist"中进行如下配置,否则影响SDK的使用. <key>NSApp ...

  3. 在Linux中安装JDK的步骤

    相信不少学习Java的朋友都在Windows操作系统中安装过JDK,这里就不对JDK做详细的介绍了. 在Windows下安装JDK可参考:JDK的安装和配置 1.下载JDK 我们可以去官网(http: ...

  4. Delphi面向对象的方法

    方法是属于一个给定对象的过程和函数,方法反映的是对象的行为而不是数据,前一篇提到的对象的两个重要的方法:构造方法和析构方法. 为了使对象能执行各种功能,你能在对象中定制方法 创建一个方法用两个步骤,首 ...

  5. 【转载】PHP使用1个crontab管理多个crontab任务

    转载来自: http://www.cnblogs.com/showker/archive/2013/09/01/3294279.html http://www.binarytides.com/php- ...

  6. 如何在java中使用别人提供的jar包进行导入,编译,运行

    一步一步往前走, 现在折分! JAR包即为上篇文章的东东. 测试JAVA文件. package com.security; import com.security.AESencrp; /** * 实现 ...

  7. android 入门-微博分享

    [2015-03-11 13:40:32 - WeiboSDK] Unable to resolve target 'android-8' 修改project.properties  target=a ...

  8. 网络模拟器WANem使用配置图文教程

    转自:http://blog.csdn.net/zm_21/article/details/25810263 WANem简介 由于公司在一些场合需要模拟真实的网络环境,如时延,丢包,抖动等,虽然使用L ...

  9. ubuntu中jdk已经安装,但是eclipse启动报错

    问题描述 在ubuntu中,jdk已经正常安装,java_home变量已经配置,但是启动eclipse的时候还是弹出以下错误信息: A Java RunTime Environment (JRE) o ...

  10. C# 指针操作图像 二值化处理

    /// <summary> /// 二值化图像 /// </summary> /// <param name="bmp"></param& ...