Gym - 101522H Hit!
1.0 s
256 MB
standard input
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.
The input consists of two lines, each describes one circle drawn on the ground. Each line contains three integers x, y 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 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.
0 0 3
3 4 3
1.5 2.5
-7 -9 3
-4 -4 5
-6 -7
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!的更多相关文章
- Codeforces Gym 100803D Space Golf 物理题
Space Golf 题目连接: http://codeforces.com/gym/100803/attachments Description You surely have never hear ...
- Codeforces Gym 100231F Solitaire 折半搜索
Solitaire 题目连接: http://codeforces.com/gym/100231/ Description 给你一个8*8棋盘,里面有4个棋子,每个棋子可以做一下某个操作之一: 1.走 ...
- [LeetCode] Design Hit Counter 设计点击计数器
Design a hit counter which counts the number of hits received in the past 5 minutes. Each function a ...
- 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 ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Buffer cache hit ratio性能计数器真的可以作为内存瓶颈的判断指标吗?
Buffer cache hit ratio官方是这么解释的:“指示在缓冲区高速缓存中找到而不需要从磁盘中读取的页的百分比.” Buffer cache hit ratio被很多人当做判断内存的性能指 ...
- LeetCode Design Hit Counter
原题链接在这里:https://leetcode.com/problems/design-hit-counter/. 题目: Design a hit counter which counts the ...
随机推荐
- 简单叨叨bootstrap按钮无限层级下拉菜单的实现
0.写在前面的话 最近看书都懈怠了,又正值新项目,虽说并不是忙得不可开交,好吧我老实交待,我就是偷懒了其实,博客也没更.言归正传,对于前端的不熟悉现在确实是个让我头疼的事情,以至于一些功能要在网络上漫 ...
- 【小程序】<image>图片实现宽度100%时,高度自适应
*.wxss样式设置 .img{ width:100% } *.wxml给<image>标签添加属性 mode="widthFix" <image class= ...
- mssql2012的分页查询
sql2102支持的分页查询 注意:以下都是先执行排序,再取行数据 select* from t_workers order by worker_id desc offset 3 rows --先 ...
- CLR回收非托管资源
一.非托管资源 在<垃圾回收算法之引用计数算法>.<垃圾回收算法之引用跟踪算法>和<垃圾回收算法之引用跟踪算法>这3篇文章中,我们介绍了垃圾回收的一些基本概念和原理 ...
- python 回溯法 子集树模板 系列 —— 14、最长公共子序列(LCS)
问题 输入 第1行:字符串A 第2行:字符串B (A,B的长度 <= 1000) 输出 输出最长的子序列,如果有多个,随意输出1个. 输入示例 belong cnblogs 输出示例 blog ...
- 【最详细最完整】在Linux 下如何打包免安装的QT程序?
在Linux 下如何打包免安装的QT程序? 版权声明:嵌入式linux相关的文章是我的学习笔记,基于Exynos 4412开发板,一部分内容是总结,一部分是查资料所得,大家可以自由转载,但请注明出处! ...
- SSIS 事件的向上传递
在SSIS中,Package是Task组件的有序组合,具有层次结构,Package处于层次结构的顶层(Root Level),对于父子包结构,父包(Parent Package)通过Execute P ...
- 前端示例MVC网站
前端示例MVC网站 ASP.NET Zero 包含了一个公共web站点的前端页面和一个登陆页面.当您第一次运行项目的时候可以看到,如下图所示: 该前端网站有两个页面,一个是主页和关于我们.这些页面的内 ...
- JVM源码---教你傻瓜式编译openjdk7(JAVA虚拟机爱好者必看)
LZ经过一个星期断断续续的研究,终于成功的搞定了JDK的成功编译与调试.尽管网络上的教程也有不少,包括源码中也有自带的编译步骤说明,但真正自己动手的话,还是会遇到不少意料之外的错误. 为了方便各位猿友 ...
- ANSYS渡槽槽身动水压力的施加(1)——矩形渡槽
前言 依据水工抗震规范中关于渡槽动水压力的部分编一个用于ANSYS渡槽模型动水压力施加的命令流,是我研究生时一直想要做的一件事,原因嘛主要是想对比一下规范提供的方法和ANSYS声学流体单元模拟水体这两 ...