C. Commentator problem
time limit per test

1 second

memory limit per test

64 megabytes

input

standard input

output

standard output

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.

Examples
Input
0 0 10
60 0 10
30 30 10
Output
30.00000 0.00000

参考博客:http://blog.csdn.net/snowy_smile/article/details/50131317

这题以我的水平还做不出来,对着几份题解啃,算是大致明白模拟退火的思路,但离真正灵活运用还差很远,有些细节的东西不太明白。
比如近似最优解为什么选重心,为什么要求精度是多少,就要循环多少次,这些我都是看着觉得有道理,但不知道依据是什么。
附ac代码:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;
struct nod {
double x,y,r;
}c[3];
double ang[3];
const int dy[4]={-1,0,0,1};
const int dx[4]={0,-1,1,0};
double po(double x) {
return x*x;
}
double dis(double x,double y,double xx,double yy) { //求距离
return sqrt(po(x-xx)+po(y-yy));
}
double val(double x,double y) { //估价函数
for(int i=0;i<3;++i) ang[i]=dis(x,y,c[i].x,c[i].y)/c[i].r; //用比较sin值来比较角度
double v=0;
for(int i=0;i<3;++i) v+=po(ang[i]-ang[(i+1)%3]); //用差值的平方和作为估价函数
return v; //这个值越小,越接近于0,三个圆的视角就越接近
}
int main() {
double x=0,y=0;
for(int i=0;i<3;i++) {
scanf("%lf%lf%lf",&c[i].x,&c[i].y,&c[i].r);
x+=c[i].x/3;
y+=c[i].y/3; //先把重心作为近似最优解
}
double err=val(x,y);
double step=1;
for(int tim=1;tim<=1e5;++tim) { //精度为小数点后五位
bool flag=0;
double X,Y;
for(int i=0;i<4;++i) { //向四个方向推进
double xx=x+dx[i]*step,yy=y+dy[i]*step;
double v=val(xx,yy);
if(v<err) { //如果找到,就继续走
err=v;
flag=1;
X=xx;Y=yy;
}
}
if(flag) {
x=X;
y=Y;
}
else step/=2; //步长减半
}
if(err<1e-6) printf("%.5lf %.5lf\n",x,y);
return 0;
}

  


 

codeforces 2C(非原创)的更多相关文章

  1. codeforces 6E (非原创)

    E. Exposition time limit per test 1.5 seconds memory limit per test 64 megabytes input standard inpu ...

  2. Linux下high CPU分析心得【非原创】

    非原创,搬运至此以作笔记, 原地址:http://www.cnitblog.com/houcy/archive/2012/11/28/86801.html 1.用top命令查看哪个进程占用CPU高ga ...

  3. CSS样式命名整理(非原创)

    非原创,具体出自哪里忘了,如果侵害您的利益,请联系我. CSS样式命名整理 页面结构 容器: container/wrap 整体宽度:wrapper 页头:header 内容:content 页面主体 ...

  4. 非原创。使用ajax加载控件

    非原创.来自博客园老赵. public class ViewManager<T> where T : System.Web.UI.UserControl { private System. ...

  5. Java 表达式解析(非原创)

    因项目需要,在网上找来一套表达式解析方法,由于原来的方法太过于零散,不利于移植,现在整理在同一文件内: 文件中包含5个内部类,源码如下: import java.util.ArrayList; imp ...

  6. Java Interface 是常量存放的最佳地点吗?(转帖学习,非原创)

    Java Interface 是常量存放的最佳地点吗?(转帖学习,非原创) 由于java interface中声明的字段在编译时会自动加上static final的修饰符,即声明为常量.因而inter ...

  7. 用RD,GR,BL三个方法内代码生成一张图片(非原创,我只是完整了代码)

    我公开以下图片的源代码,,是ppm格式的,,自己找到能打开的工具.. (非原创,我加工的代码,可直接执行运行输出,缩略图能看到效果)  这是原博客 http://news.cnblogs.com/n/ ...

  8. tp5.1 phpspreadsheet- 工具类 导入导出(整合优化,非原创,抄一抄,加了一些自己的东西,)

    phpspreadsheet-工具类 导入导出(整合优化,非原创,抄一抄,加了一些自己的东西)1. composer require phpoffice/phpspreadsheet2. 看最下面的两 ...

  9. Vue 仿QQ左滑删除功能(非原创)

    非原创,摘选来源:http://www.jb51.net/article/136221.htm. 废话不多说,相当实用,先记录. Html代码: <div class="contain ...

  10. 老男孩Django笔记(非原创)

    .WEB框架 MVC Model View Controller 数据库 模板文件 业务处理 MTV Model Template View 数据库 模板文件 业务处理 ############## ...

随机推荐

  1. 创建Django REST framework工程

    1.创建工程虚拟环境 2.创建工程目录和调整目录结构: 创建Django的项目 创建docs 用于存放一些说明文档资料 创建scripts 用于存放管理脚本文件 创建logs 用于存在日志 在与项目同 ...

  2. commons-lang3相关类实例

    一.ArrayUtils //1.判断两个数组长度是否相等 ArrayUtils.isSameLength(new int[] {1,2,3,4}, new int[] {1,2,3,4});//tr ...

  3. LocalDateTime、OffsetDateTime、ZonedDateTime互转,这一篇绝对喂饱你

    前言 你好,我是A哥(YourBatman). 在JSR 310日期时间体系了,一共有三个API可用于表示日期时间: LocalDateTime:本地日期时间 OffsetDateTime:带偏移量的 ...

  4. 【Azure 应用服务】App Service中,为Java应用配置自定义错误页面,禁用DELETE, PUT方法

    问题定义 使用Azure应用服务(App Service),部署Java应用,使用Tomcat容器,如何自定义错误页面呢?同时禁用DELETE, PUT方法 解决办法 如何自定义错误页面呢?需要在 J ...

  5. 转 Fiddler2 下断点修改HTTP报文

    文章转自:https://www.cnblogs.com/zhengna/p/10861893.html 一 Fiddler中设置断点修改HTTP请求 方法1:全局断点.Rules-->Auto ...

  6. 容器调度 • Docker网络 • 持续交付 • 动态运行应用程序 部署的多元化

    <英雄联盟>在线服务运维之道 - InfoQ https://www.infoq.cn/article/running-online-services-riot/ 第一章 简 介 我是Jo ...

  7. c 越界 数组越界

    int main(int argc, char* argv[]){ int i = 0; int arr[3] = {0}; for(; i<=3; i++){ arr[i] = 0; prin ...

  8. calc, support, media各自的含义及用法?

    @support主要是用于检测浏览器是否支持CSS的某个属性,其实就是条件判断,如果支持某个属性,你可以写一套样式,如果不支持某个属性,你也可以提供另外一套样式作为替补. calc() 函数用于动态计 ...

  9. Django(自定义过滤器和自定义标签)

    模版是一个用django模版语言标记过的python字符串.模版可以包含模版标签和变量. 模版标签是在一个模版里起作用的标记.比如,一个模版标签可以产生控制结构的内容(if或者for),可以获取数据库 ...

  10. (转)pip和easy_install使用方式

    easy_install 跟 pip 都是 Python 的套件管理程式,有了它們,在使用 Python 開發程式的時候會帶來不少方便. easy_install 和 pip 有什麼不一樣?據 pip ...