H. Hit!
time limit per test

1.0 s

memory limit per test

256 MB

input

standard input

output

standard output

"Hit!" is a popular game in ancient Byteland.

The very first version of the game is quite simple: each player picks up a stone and throws it at a circle drawn on the ground. A player wins if his/her stone lands inside the circle.

After 20 years of practice, Bitman, a young man living in ancient Byteland, has mastered the skill of throwing stones – he can throw a stone at any specific place he wants. With such skill, Bitman plays "Hit!" without losing a single game. He simply targets every stone at the center of the circle!

The King of Hackerland hears the story of Bitman and wants to challenge him with a harder, though still very simple, version of "Hit!".

In each game, two circles which share a positive common area are drawn on the ground. In order to win, the player must throw a stone at the common area of the two circles.

As Bitman had no idea how to target his stone at the common area, he asks for your help. Given the coordinates of the centers and radii of the two circles, please tell Bitman the coordinates of any point he can target at such that he can win the game.

For simplicity, you can consider the landing position of the stone as a single point.

Input

The input consists of two lines, each describes one circle drawn on the ground. Each line contains three integers xy and r, denoting respectively the x-coordinate, y-coordinate, and the radius of a circle.

All coordinates have their absolute value no more than 100, and 1 ≤ r ≤ 100 for both circles.

Output

Output two numbers, the x-coordinate and y-coordinate of a point where Bitman can throw his stone at to win the game.

Your answer will be accepted if for each of the two circles, the point lies inside the circle or that the distance between the point and the circle is not greater than 10 - 5.

Examples
input
0 0 3
3 4 3
output
1.5 2.5
input
-7 -9 3
-4 -4 5
output
-6 -7
Note

In the first sample, (1.5, 2.5) is a possible answer as it lies inside the common area of two circles drawn. Please note that there exists more than one possible answer in this case. For example, (2, 2), (1, 2) and (2.1, 1.87) are also possible answers.

思路:

水题,特判下两个圆的直径大于两圆心距离的情况,这时只要输出圆心就好了。还以为会卡精度,敲了半天,结果告诉队友特判,队友一顿乱敲没考虑精度直接过了。。mmp.

实现代码:

#include<bits/stdc++.h>
using namespace std; int main()
{
double x1,x2,y1,y2,z1,z2;
cin>>x1>>y1>>z1;
cin>>x2>>y2>>z2;
double len = pow((x2 - x1),) + pow((y2 - y1),);
len = sqrt(len);
//cout<<"len :"<<len<<endl;
double len1 = len - z1;
double len2 = len - z2;
//cout<<len1<<" "<<len2<<endl;
if(len1<=){
cout<<x2<<" "<<y2<<endl;
return ;
}
else if(len2<=){
cout<<x1<<" "<<y1<<endl;
return ;
}
double f1 = x2-x1;
double f2 = y2-y1;
double k = len2/len;
//cout<<k<<endl;
f1 *= k;
f2 *= k;
//printf("%.6lf\n",len2);
double ans;
while(){
ans = pow(f1,)+pow(f2,);
ans = sqrt(ans);
//printf("%.6lf\n",ans);
if(abs(ans - len2)<0.00001)
break;
else{
if(ans-len2<0.00001){
f1+=0.000001;f2+=0.000001;}
else if(ans-len2>0.00001){
f1-=0.000001;f2-=0.000001;}
}
}
printf("%.6lf %.6lf",x1+f1,y1+f2);
//cout<<pow((x1+f1),2)+pow((y1+f2),2)<<endl;
}

Gym - 101522H Hit!的更多相关文章

  1. Codeforces Gym 100803D Space Golf 物理题

    Space Golf 题目连接: http://codeforces.com/gym/100803/attachments Description You surely have never hear ...

  2. Codeforces Gym 100231F Solitaire 折半搜索

    Solitaire 题目连接: http://codeforces.com/gym/100231/ Description 给你一个8*8棋盘,里面有4个棋子,每个棋子可以做一下某个操作之一: 1.走 ...

  3. [LeetCode] Design Hit Counter 设计点击计数器

    Design a hit counter which counts the number of hits received in the past 5 minutes. Each function a ...

  4. ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力

     Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS     Memory Limit:65536KB     64bit IO Fo ...

  5. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  6. ACM: Gym 101047E Escape from Ayutthaya - BFS

    Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I6 ...

  7. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  8. Buffer cache hit ratio性能计数器真的可以作为内存瓶颈的判断指标吗?

    Buffer cache hit ratio官方是这么解释的:“指示在缓冲区高速缓存中找到而不需要从磁盘中读取的页的百分比.” Buffer cache hit ratio被很多人当做判断内存的性能指 ...

  9. LeetCode Design Hit Counter

    原题链接在这里:https://leetcode.com/problems/design-hit-counter/. 题目: Design a hit counter which counts the ...

随机推荐

  1. 2PC AND 3PC

    一.分布式数据一致性 在分布式系统中,为了保证数据的高可用,通常会将数据保留多个副本(replica),这些副本会放置在不同的物理的机器上. (1)什么是数据一致性 在数据有多份副本的情况下,如果网络 ...

  2. UWP ListView 绑定 单击 选中项 颜色

    refer: https://www.cnblogs.com/lonelyxmas/p/7650259.html using System; using System.Collections.Gene ...

  3. 20155227《网络对抗》Exp7 网络欺诈防范

    20155227<网络对抗>Exp7 网络欺诈防范 实践内容(3.5分) 本实践的目标理解常用网络欺诈背后的原理,以提高防范意识,并提出具体防范方法.具体实践有 (1)简单应用SET工具建 ...

  4. 20155227《网络对抗》Exp6 信息收集与漏洞扫描

    20155227<网络对抗>Exp6 信息收集与漏洞扫描 实践目标 掌握信息搜集的最基础技能与常用工具的使用方法. 基础问题回答 哪些组织负责DNS,IP的管理. 全球根服务器均由美国政府 ...

  5. 20155313 杨瀚 《网络对抗技术》实验五 MSF基础应用

    20155313 杨瀚 <网络对抗技术>实验五 MSF基础应用 一.实验目的 本实验目标是掌握metasploit的基本应用方式,重点常用的三种攻击方式的思路.具体需要完成: 1.一个主动 ...

  6. HQL语句的3个小技巧

    1.巧用new map        在查询表中部分字段的值时,我们可以用map来封装这些字段的值,可以提高查询效率,而且查出数据也更小,传输到页面的速度也更快.  如:查询角色时,我们只想要 id, ...

  7. Servlet——提交表单信息,Servlet之间的跳转

    HTML表单标签:<form></form> 属性: actoion:  提交到的地址,默认为当前页面 method:  表单提交方式 有get和post两种方式,默认为get ...

  8. mfc CSpinButton

    知识点: CSliderCtrl(滑块)控件 CSliderCtrl常用属性 CSliderCtrl类常用成员函数 CSliderCtrl运用示例 一.CSliderCtr常用属性 Orientati ...

  9. 开源微信Http协议Sdk【实现登录/获取好友列表/修改备注/发送消息】

    基于微信Http协议封装的一个Sdk,目前实现了以下功能:. 1:扫码登录(检测二维码扫描状态) 2:获取最近联系人.群组.所有联系人 3:修改好友备注 4:给好友发送消息 暂且这么多,也没多余的时间 ...

  10. centos 7 git的管理和使用

    一.linux 安装git (服务端) 1.首先创建用户账号 useradd zlx passwd zlx .... 2.创建目录git仓库 mkdir zlx_git.git 3.赋权限 chown ...