题目链接
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

思路

从中心开始移动,判断误差,不断逼近答案。

AC

#include<bits/stdc++.h>
using namespace std;
struct point{double x, y, r;
}circle[4];
double eps = 1e-5;
double dis[4];
double find_dis(point a, point b) {return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
double solve(point x) {double error = 0;for (int i = 0; i < 3; i++) {dis[i] = find_dis(x, circle[i]) / circle[i].r;}// 如果是答案,三个dis值应该相同。误差分析:差的平方,加上平方更加精确 for (int i = 0; i < 3; i++) {error += (dis[i] - dis[(i + 1) % 3]) * (dis[i] - dis[(i + 1) % 3]); }return error;
}
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int main() {// 假设起始点是重心 point ans;ans.x = 0; ans.y = 0; ans.r = 0;
//  freopen("in.txt", "r", stdin);for (int i = 0; i < 3; i++) {double x, y, r;scanf("%lf%lf%lf", &x, &y, &r);circle[i].x = x;circle[i].y = y;circle[i].r = r;ans.x += x / 3;ans.y += y / 3;}// 每次移动的步数 double move = 1.0;double error = solve(ans);while (move >= eps  ) { point new_point;int flag = 1;// 枚举四个方向 for (int i = 0; i < 4; i++) {new_point.x = ans.x + dx[i] * move;new_point.y = ans.y + dy[i] * move;double temp = solve(new_point);if (temp < error) {flag = 0;error = temp;ans.x = new_point.x;ans.y = new_point.y;    }}if (flag)   move /= 2;  }//存在答案输出 if (error < eps)printf("%.5lf %.5lf\n", ans.x, ans.y);return 0;
}

C. Commentator problem相关推荐

  1. Commentator problem(CF 2)

    题目链接 题目大意: 给定三个圆,询问是否存在点满足该点与三个圆夹角均相等,若存在多组解返回夹角最大值. 圆外一点到两圆夹角均相等: 即 sina = sinb = r1 / d1 = r2 / d2 ...

  2. linux下yum错误:[Errno 14] problem making ssl connection Trying other mirror.

    所有的base 都要取消注释 mirrorlist 加上注释 另外所有的enable都要设为零 目录 今天是要yum命令安装EPEL仓库后 yum install epel-release 突然发现y ...

  3. A + B Problem

    1001: A + B Problem Description 计算 A + B. Input 多组测试数据,每组测试数据占一行,包括2个整数. Output 在一行中输出结果. Sample Inp ...

  4. Error:(49, 1) A problem occurred evaluating project ':guideview'. Could not read script 'https://r

    出现问题如下: Error:(49, 1) A problem occurred evaluating project ':guideview'. > Could not read script ...

  5. #418 Div2 Problem B An express train to reveries (构造 || 全排列序列特性)

    题目链接:http://codeforces.com/contest/814/problem/B 题意 : 有一个给出两个含有 n 个数的序列 a 和 b, 这两个序列和(1~n)的其中一个全排列序列 ...

  6. ADPRL - 近似动态规划和强化学习 - Note 3 - Stochastic Infinite Horizon Problem

    Stochastic Infinite Horizon Problem 3.Stochastic Infinite Horizon Problem 定义3.1 无限范围的马尔可夫决策过程 (Marko ...

  7. ADPRL - 近似动态规划和强化学习 - Note 2 - Stochastic Finite Horizon Problem

    2. Stochastic Finite Horizon Problem 在这一节中主要介绍了随机DP算法来解决不确定性下的有限地范围问题,如Denition 1.4所述,它被表述为一个组合优化问题. ...

  8. There was a problem confirming the ssl certificate ……

    在安装一个Python库onetimepass时发生下面的问题: pip install onetimepass Could not fetch URL https://pypi.python.org ...

  9. HDU 1757 A Simple Math Problem

    Problem Description Lele now is thinking about a simple function f(x). If x < 10 f(x) = x. If x & ...

最新文章

  1. 2018全球科技创新报告
  2. OpenStack 实现技术分解 (7) 通用库 — oslo_config
  3. maven私服的配置使用
  4. boost::geometry::tuples用法的测试程序
  5. django(7)modelform操作及验证、ajax操作普通表单数据提交、文件上传、富文本框基本使用...
  6. 牛客网_PAT乙级_1031. 查验身份证(15)【class new一个数组】
  7. CSS3定位和浮动详解
  8. STM32 串口接收流程-串口接收中断
  9. 线程与进程最通俗易懂的解释(附面试题与答案)
  10. Processing编程学习指南2.5 Processing中的代码
  11. 第一课 矩阵的行图像与列图像(麻省理工公开课:线性代数)【转载】
  12. [软考]项目管理常用案例总结
  13. 如何查找一篇论文的实现代码从而复现论文?以及如何查找一篇论文被哪些论文引用?
  14. 2021-07-27 Vue修改主页
  15. 安装shipyard
  16. 【Linux】资源查看top显示信息说明|top、iftop、iotop、htop、atop工具
  17. C语言入门条件运算符
  18. Java实现bt文件下载、制作、解析、磁力链接
  19. 免费获得筹码分布接口交易数据,Tushare的使用方法
  20. 天九共享:突破“邓巴数字”桎梏 创造资源能力圈

热门文章

  1. 关于scriptManager与JS代码兼容问题
  2. mysql官网二进制包_mysql二进制包安装与配置实战记录
  3. C# 系统应用之鼠标模拟技术及自动操作鼠标
  4. iOS之深入解析Runtime的objc_msgSend“慢速查找”底层原理
  5. iOS之深入解析消息转发objc_msgSend的应用场景
  6. 【数据结构与算法】之有序数组中的单一元素的算法
  7. 2015年第六届蓝桥杯 - 省赛 - C/C++大学B组 - C. 三羊献端
  8. 2020\Simulation_1\5.数位递增的数
  9. 10.2.4 练习题
  10. 信息学奥赛一本通(C++)在线评测系统——基础(一)C++语言——1075:药房管理