Codeforces Beta Round #2 C. Commentator problem 模拟退火
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 模拟退火的更多相关文章
- Codeforces Beta Round #2 C. Commentator problem
模拟退火果然是一个非常高端的东西,思路神马的全然搞不懂啊~ 题目大意: 给出三个圆,求一点到这三个圆的两切线的夹角相等. 解题思路: 对于这个题来说还是有多种思路的 .只是都搞不明确~~ /害羞脸 ...
- Codeforces Beta Round #17 A - Noldbach problem 暴力
A - Noldbach problem 题面链接 http://codeforces.com/contest/17/problem/A 题面 Nick is interested in prime ...
- 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]中有多少个数 ...
- Codeforces Beta Round#2
Codeforces Beta Round#2 http://codeforces.com/contest/2 A 模拟题 #include<bits/stdc++.h> using na ...
- Codeforces Beta Round #5 B. Center Alignment 模拟题
B. Center Alignment 题目连接: http://www.codeforces.com/contest/5/problem/B Description Almost every tex ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #13 C. Sequence (DP)
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
随机推荐
- Vuex 基本概念
Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式.它采用集中式存储管理应用的所有组件的状态,并以相应的规则保证状态以一种可预测的方式发生变化. 每一个 Vuex 应用的核心就是 stor ...
- 如何更新远程主机上的 Linux 内核
如何更新远程主机上的 Linux 内核 http://blog.csdn.net/robertsong2004/article/details/47277121 转载至:http://www.tiny ...
- Linux下用freetds执行SQL Server的sql语句和存储过程
Linux下用freetds执行SQL Server的sql语句和存储过程 http://www.linuxidc.com/Linux/2012-06/61617.htm freetds相关 http ...
- 经典卷积网络模型 — VGGNet模型笔记
一.简介 VGGNet是计算机视觉组(Visual Geometry Group)和Google DeepMind公司的研究员一起研究的深度卷积神经网络.VGGNet探索了卷积神经网络深度与性能之间的 ...
- js 获取html5的data属性
我以前一直以为只能用jquery的data()来获取 哈哈 是我太弱了 <!DOCTYPE html> <html> <head> <title>dat ...
- redis 安装配置
reids 安装配置 1.1 下载软件包 [root@node01 ~]# mkdir -p /data/src/ [root@node01 ~]# cd /data/src/ [root@node0 ...
- 转载--MyBaits中的#和$的区别
面试被问到了,百度了下,原文地址:mybatis中的#和$的区别 1. #将传入的数据都当成一个字符串,会对自动传入的数据加一个双引号.如:order by #user_id#,如果传入的值是111, ...
- 对于mysql加索引,删除索引,添加列,删除列,修改列顺序的最佳办法测试
1.首先进行数据训的XltraBackup备份,有备无患,切记切记! 2.mysql -uroot -pD******** -- 导出csv文件 use dsideal_db; MariaDB [ds ...
- PHP的命名空间namespace
对于命名空间,官方文档已经说得很详细[查看],我在这里做了一下实践和总结. 命名空间一个最明确的目的就是解决重名问题,PHP中不允许两个函数或者类出现相同的名字,否则会产生一个致命的错误.这种情况下只 ...
- 关于Vue-cli的跨域解决
由于Vue-cli服务器是跑在node环境下的8080端口,我们的php代码可能在Apache环境下的7070端口,这个时候就会出现跨域 此刻这段php代码在7070端口上 如果直接去访问 页面报错 ...