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 ...
随机推荐
- 常用的php数组函数
以下是自己比较常用的数组函数 数组元素增加减少array_pusharray_poparray_shiftarray_unshift array_splice (对数组的增删改) array_sli ...
- AS3.0 自定义右键菜单类
AS3.0 自定义右键菜单类: /** * 自定义右键菜单类 * 自定义菜单项不得超过15个,每个标题必须至少包含一个可见字符. * 标题字符不能超过100个,并且开头的空白字符会被忽略. * 与任何 ...
- 20155301 Web基础
20155301 Web基础 1.基础问题回答 (1)什么是表单 答: 表单是一个包含表单元素的区域. 表单元素是允许用户在表单中(比如:文本域.下拉列表.单选框.复选框等等)输入信息的元素 (2)浏 ...
- [清华集训2015 Day1]玛里苟斯-[线性基]
Description Solution 考虑k=1的情况.假设所有数中,第i位为1的数的个数为x,则最后所有的子集异或结果中,第i位为1的个数为$(C_{k}^{1}+C_{k}^{3}+...)$ ...
- flask 与 vue.js 2.0 实现 todo list
实现了后端与前端分离,后端提供 RESTful api. 后端 flask 与前端 vue 的数据传输都是 json. 本文使用 vue.js 2.0 对前一个例子:flask, SQLAlchemy ...
- Docker-compose部署gitlab中文版
目录 Docker-compose部署gitlab 1.安装Docker 2.安装Docker-compose 3.安装Gitlab Docker-compose部署gitlab 1.安装Docker ...
- bootstrap-validator基本使用(自定义验证身份证号和手机号)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...
- Dubbo+zookeeper搭建环境学习笔记
Dubbo背景和简介 Dubbo开始于电商系统,因此在这里先从电商系统的演变讲起. 1.单一应用框架(ORM) 当网站流量很小时,只需一个应用,将所有功能如下单支付等都部署在一起,以减少部署节点和成本 ...
- laraver框架学习
最近开始学习laravel框架,这个框架在国外很流行,近些年开始在国内流行.自己而是刚开始学习这个框架. 使用composer 更新系统内的依赖包 在终端输入:composer update Entr ...
- Linux shell(5)
shell程序流程控制的三大结构: 1. 顺序结构 2.选择结构 3.循环结构 顺序结构的定义: 顺序结构的程序设计是最简单的一种结构,它的执行顺序自上而下,依次执行,因此,我们只要按照解决问题的思路 ...