C. Commentator problem

题目连接:

http://www.codeforces.com/contest/2/problem/C

Description

The Olympic Games in Bercouver are in full swing now. Here everyone has their own objectives: sportsmen compete for medals, and sport commentators compete for more convenient positions to give a running commentary. Today the main sport events take place at three round stadiums, and the commentator's objective is to choose the best point of observation, that is to say the point from where all the three stadiums can be observed. As all the sport competitions are of the same importance, the stadiums should be observed at the same angle. If the number of points meeting the conditions is more than one, the point with the maximum angle of observation is prefered.

Would you, please, help the famous Berland commentator G. Berniev to find the best point of observation. It should be noted, that the stadiums do not hide each other, the commentator can easily see one stadium through the other.

Input

The input data consists of three lines, each of them describes the position of one stadium. The lines have the format x,  y,  r, where (x, y) are the coordinates of the stadium's center ( -  103 ≤ x,  y ≤ 103), and r (1 ≤ r  ≤ 103) is its radius. All the numbers in the input data are integer, stadiums do not have common points, and their centers are not on the same line.

Output

Print the coordinates of the required point with five digits after the decimal point. If there is no answer meeting the conditions, the program shouldn't print anything. The output data should be left blank.

Sample Input

0 0 10

60 0 10

30 30 10

Sample Output

30.00000 0.00000

Hint

题意

给你三个圆,现在你要找一个点,使得这个点和每个圆形成的切线的角度都是一样的。

如果有多个点,那么选择角度最大的那个点。

题解:

假设离那个圆的圆心的距离为D,那么ang = asin(D/r)这个很显然。

然后我们确保ang都相同就好了。

然后角度越大,其实就是距离越近。

然后这个东西直接退火一下就好了。

嘟嘟嘟,随便退一退。

代码

#include<bits/stdc++.h>
using namespace std;
struct node
{
double x,y;
double r;
}p[3];
double dis(double x,double y,node t)
{
return sqrt((x-t.x)*(x-t.x)+(y-t.y)*(y-t.y));
}
double cost(double x,double y)
{
double ang[3];
for(int i=0;i<3;i++)
ang[i]=dis(x,y,p[i])/p[i].r;
double d[3];
for(int i=0;i<3;i++)
d[i]=ang[i]-ang[(i+1)%3];
return d[0]*d[0]+d[1]*d[1]+d[2]*d[2];
}
int main()
{
for(int i=0;i<3;i++)
cin>>p[i].x>>p[i].y>>p[i].r;
double x=0,y=0;
for(int i=0;i<3;i++)
x+=p[i].x/3,y+=p[i].y/3;
double t=1.0;
while(t>1e-5)
{
int flag = 0;
if(cost(x+t,y)<cost(x,y))x+=t,flag=1;
else if(cost(x,y+t)<cost(x,y))y+=t,flag=1;
else if(cost(x-t,y)<cost(x,y))x-=t,flag=1;
else if(cost(x,y-t)<cost(x,y))y-=t,flag=1;
if(!flag)t*=0.5;
}
if(fabs(cost(x,y))<1e-5)printf("%.12f %.12f\n",x,y);
}

Codeforces Beta Round #2 C. Commentator problem 模拟退火的更多相关文章

  1. Codeforces Beta Round #2 C. Commentator problem

    模拟退火果然是一个非常高端的东西,思路神马的全然搞不懂啊~ 题目大意: 给出三个圆,求一点到这三个圆的两切线的夹角相等. 解题思路: 对于这个题来说还是有多种思路的 .只是都搞不明确~~   /害羞脸 ...

  2. Codeforces Beta Round #17 A - Noldbach problem 暴力

    A - Noldbach problem 题面链接 http://codeforces.com/contest/17/problem/A 题面 Nick is interested in prime ...

  3. Codeforces Beta Round #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

  4. Codeforces Beta Round#2

    Codeforces Beta Round#2 http://codeforces.com/contest/2 A 模拟题 #include<bits/stdc++.h> using na ...

  5. Codeforces Beta Round #5 B. Center Alignment 模拟题

    B. Center Alignment 题目连接: http://www.codeforces.com/contest/5/problem/B Description Almost every tex ...

  6. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  7. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  8. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

  9. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

随机推荐

  1. 利用procdump+Mimikatz 绕过杀软获取Windows明文密码

    思路: 就是通过系统自带的procdump去下载存储用户名密码的文件(应该不能那么说这个文件,但是这样理解没问题),然后用猕猴桃读取. procdump.exe Procdump是一个轻量级的Sysi ...

  2. Django 1.10中文文档-第一个应用Part4-表单和通用视图

    本教程接Part3开始.继续网页投票应用程序,并将重点介绍简单的表单处理和精简代码. 一个简单表单 更新一下在上一个教程中编写的投票详细页面的模板polls/detail.html,让它包含一个HTM ...

  3. Vue基本指令

    模板对象 vue指令 一:模板对象 <!DOCTYPE html> <html lang="en"> <head> <meta chars ...

  4. Low-overhead enhancement of reliability of journaled file system using solid state storage and de-duplication

    A mechanism is provided in a data processing system for reliable asynchronous solid-state device bas ...

  5. [caffe error] undefined reference to `inflateValidate@ZLIB_1.2.9'

    undefined reference to `inflateValidate@ZLIB_1.2.9' Makefile.config添加一行LINKFLAGS := -Wl,-rpath,$(HOM ...

  6. [Deep dig] ViewController初始化过程调查

    代码:https://github.com/xufeng79x/ViewControllerLife 1.简介: 介绍xib方式.storyborad方式以及code方式下ViewController ...

  7. windows7配置python和django的开发环境

    直接上图,这是我在我的电脑配置windows7python和django开发环境的所有用到的软件 要求不高,只需要这几个软件的版本相一致就行, 需要注意的是软件安装时需要统一是32位或者64位的软件, ...

  8. 取消myeclipse自动进入workspace

    进入到C:\Program Files\MyEclipse 6.5\eclipse\configuration\.settings目录, 修改SHOW_WORKSPACE_SELECTION_DIAL ...

  9. 接口测试Session/Cookie笔记(二)

    Windows系统运行计算器命令:calc python显示上一步操作命令:Alt+p python显示上一步操作结果:_(英文下划线) Session是存放在服务器的键值对 ,用于保存客户端的某个特 ...

  10. EL表达式使用时出现NumberFormatException异常

    从后端数据库取出书本集合,然后循环输出到前端表格: <c:forEach items="${bookManagedBean.bookList}" var="book ...