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. AVA编程中button按钮,actionlistener和mouseClicked区别

    在java的编程中,对于按钮button 有两个事件: 1.actionPerformed 2.mouseClicked 区别: actionPerformed:一般事件,仅侦听鼠标左键的单击事件,右 ...

  2. QT串口助手(二):参数配置

    作者:zzssdd2 E-mail:zzssdd2@foxmail.com 一.前言 主要实现功能 串口参数的配置:波特率.数据位.停止位.校验位 本机串口设备的查询与添加显示 串口设备的手动更新与打 ...

  3. 给dtcms增加模板自动生成功能

    作为dtcms的使用者你是不是像我一样,也在不停的修改模板之后要点击生成模板浪费了很多开发模板的时间? 那就跟我一起给dtcms增加一个开发者模式,当模板修改完成之后,直接刷新页面就能看到效果,而不再 ...

  4. 同一份数据,Redis为什么要存两次

    前言 在 Redis 中,有一种数据类型,当在存储的时候会同时采用两种数据结构来进行分别存储,那么 Redis 为什么要这么做呢?这么做会造成同一份数据占用两倍空间吗? 五种基本类型之集合对象 Red ...

  5. uni-app开发经验分享十一: uniapp iOS云打包修改权限提示语

    打包提交appstore如果用到了如下权限需要修改提示语,详细描述使用这个权限的原因,如不修改提示语appstore审核可能会被拒绝.Apple的原则是,如果一个app想要申请用户同意某个隐私信息访问 ...

  6. SUGA

    愿试炼的终点是花开万里 愿以渺小启程伟大结束 ----闵玧其

  7. 【LinuxShell】wget 命令详解

    参数 待补充 返回值 code means  0  No problems occurred  1  Generic error code  2  Parse error - for instance ...

  8. 初识 Nginx服务配置

    Nginx 是一个免费的,开源的,高性能的HTTP服务器和反向代理,以及IMAP / POP3代理服务器. Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消耗而闻名.很多高知名度的网站 ...

  9. Java执行Dos-Shell脚本

    Java执行Dos-Shell脚本 1.介绍 2.调用shell脚本 2.1 获取键盘输入 2.2 构建指令 2.3 Java代码 3.Java调用Shell并传入参数 4.Java调用远程的Shel ...

  10. js基础(使用Canvas画图)

    HTML5的元素提供了一组JavaScript API,让我们可以动态地创建图形和图像. 图形是在一个特定的上下文中创建的,而上下文对象目前有两种.第一种是2D上下文,可以执行原始的绘图操作, 比如: ...