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++. ...
随机推荐
- Metlnfo cms后台getshell漏洞复现
整体思路 挖掘伪全局变量 然后找可控参数进行利用#伪全局变量:可理解为全局变量,例部分CMS为了全局过滤SQL注入或者XSS之类的漏洞就会将GET.POST.COOKIE等请求借入全局然后直接过滤.这 ...
- Linux内核中内存cache的实现【转】
Linux内核中内存cache的实现 转自:http://blog.chinaunix.net/uid-127037-id-2919545.html 本文档的Copyleft归yfydz所有,使用 ...
- 如何更新远程主机上的 Linux 内核
如何更新远程主机上的 Linux 内核 http://blog.csdn.net/robertsong2004/article/details/47277121 转载至:http://www.tiny ...
- Django 国内最全教程
https://code.ziqiangxuetang.com/django/django-tutorial.html
- Laravel artisan commands
使用php artisan list 可以看到artisan的所有命令以及选项. 当然你也可以在此基础上扩展自己的命令. 1. key 1.1 key:generate 这是一个加密秘钥,用于保证安全 ...
- python运行原理/python解释器
先Mark一下这个主题,内容待添加... 参考文章: [1]http://www.cnblogs.com/restran/p/4903056.html [2]https://blog.hakril.n ...
- AC日记——[SDOI2009]HH的项链 洛谷 P1972
[SDOI2009]HH的项链 思路: 莫队: 代码: #include <bits/stdc++.h> #define maxn 100005 #define maxm 400005 # ...
- 2t3ik、ddgs与Linux异常文件下载处理
异常1: 这样的邮件发生了两周了,烦得很.进入服务器,用top看来下进程. 解决办法 首先 kill 相关PID 进入/tmp/ 删除相关文件 rm -rf 2t3ik相关文件 不给相关文件修改权 ...
- 转:攻击JavaWeb应用[3]-SQL注入
转:http://static.hx99.net/static/drops/tips-236.html 攻击JavaWeb应用[3]-SQL注入 园长 · 2013/07/16 18:28 注:本节重 ...
- jsp页面中获取session中的值
Jsp中获取Session: session是jsp的内置对象,所以你可以直接写在jsp的 <% session.setAttribute("a", b); //把b放到se ...