Spoj-BLMIRINA Archery Training
Mirana is an archer with superpower. Every arrow she shoots will get stronger the further it travels. Mirana is currently on the way to warzone.
Since the road is still a long way, Mirana remembers about when she's still in training. In each of her training, Mirana stands on the (0,0) point in a cartesian scale. From that point, she must shoot a circle centered in (x,y) with radius r. Everything happens in z=0.
To maximize the arrow's power, Mirana must shoot the furthest point of the enemy possible. Her arrow travels at the speed of light and will instantly stops the moment it touches the target. On the target, determine the coordinate point that Mirana has to shoot to get maximum power. If multiple coordinate exists, choose the one with the lower x value.
Input
First line is T, number of training (T < 100000). Next T lines each contains 3 space separeted integers x, y, and r for each training (1 < r < x,y < 1000)
Output
For each training, output a line containing the coordinate of the arrow's destination separated by space. Output until 6 digit after decimal point.
Example
Input:
3
1 1 1
2 2 1
4 5 2
Output:
0.000000 1.000000
1.088562 2.411438
2.126155 5.699076
有一个圆心在(x0,y0),半径是r的圆,要过原点做它的切线,求两个切点中x坐标更小的那个的坐标
解方程……很烦
联立两式:(x-x0)^2+(y-y0)^2=r^2, x^2+y^2=x0^2+y0^2-r^2,得到过两切点的直线方程:
x0x+y0y=x0^2+y0^2-r^2
令k=x0^2+y0^2-r^2,则x0x+y0y=k
上式带入x^2+y^2=k,得到一个x的一元二次方程
(x0^2+y0^2)x^2+(-2kx0)x+(k^2-y^2k)=0
解出来x取小的那个(这肯定有两解的)
然后带回x0x+y0y=k,得到y
这里似乎y会有点精度问题?比如0变成-0.000000
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define mkp(a,b) make_pair(a,b)
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void work()
{
double x,y,r;scanf("%lf%lf%lf",&x,&y,&r);
if (x*x+y*y<=r*r){puts("0.00000000 0.00000000");return;}
long double k=x*x+y*y-r*r;
long double A=(x*x+y*y),B=-*k*x,C=k*k-y*y*k;
long double delta=sqrt(B*B-*A*C);
long double ansx=min((-B+delta)/(*A),(-B-delta)/(*A)),ansy=sqrt(k-ansx*ansx);
if (fabs(ansx*x+ansy*y-k)>1e-)ansy=-ansy;
double xx=ansx,yy=ansy;
printf("%.8f %.8f\n",xx,yy);
}
int main()
{
int T=read();
while (T--)work();
}
Spoj BLMIRINA
Spoj-BLMIRINA Archery Training的更多相关文章
- SPOJ VLATTICE Visible Lattice Points (莫比乌斯反演基础题)
Visible Lattice Points Consider a N*N*N lattice. One corner is at (0,0,0) and the opposite one is at ...
- HDU 4348 SPOJ 11470 To the moon
Vjudge题面 Time limit 2000 ms Memory limit 65536 kB OS Windows Source 2012 Multi-University Training C ...
- BZOJ 2588: Spoj 10628. Count on a tree [树上主席树]
2588: Spoj 10628. Count on a tree Time Limit: 12 Sec Memory Limit: 128 MBSubmit: 5217 Solved: 1233 ...
- hdu 4946 2014 Multi-University Training Contest 8
Area of Mushroom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 2016 Multi-University Training Contests
2016 Multi-University Training Contest 1 2016 Multi-University Training Contest 2 2016 Multi-Univers ...
- SPOJ DQUERY D-query(主席树)
题目 Source http://www.spoj.com/problems/DQUERY/en/ Description Given a sequence of n numbers a1, a2, ...
- 2016 Multi-University Training Contest 2 D. Differencia
Differencia Time Limit: 10000/10000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- 2016 Multi-University Training Contest 1 G. Rigid Frameworks
Rigid Frameworks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
随机推荐
- 如何在Mac OS X中开启或关闭显示隐藏文件命令
打开终端,输入:defaults write com.apple.finder AppleShowAllFiles -bool true 此命令显示隐藏文件defaults write com.app ...
- Codeforces Round #277.5 (Div. 2)-D. Unbearable Controversy of Being
http://codeforces.com/problemset/problem/489/D D. Unbearable Controversy of Being time limit per tes ...
- win10文件共享的实现
1)启动网络发现 打开网络共享中心->更改高级共享设置->修改如下 2)如果需要其他客户端无密码访问 修改如下: 3)如果打算使用Guest访问 用户帐户->管理帐户 ...
- Java中的线程--并发库中的集合
线程中的知识点基本都已经学完了,看看Java5并发库中提供的集合... 一.可堵塞队列 队列包含固定长度的队列和不固定长度的队列 ArrayBlockQueue中只有put()方法和take()方法才 ...
- ios 团购信息客户端demo(三)
接上二篇的内容,今天我们就来介绍一下如何将解析出来的数据放入AQGridView中显示出来,因为我们的工程中已经将AQGridView导入了,所以我们在KKFirstViewController中直接 ...
- 【树形dp 最长链】bzoj1912: [Apio2010]patrol 巡逻
富有思维性的树形dp Description Input 第一行包含两个整数 n, K(1 ≤ K ≤ 2).接下来 n – 1行,每行两个整数 a, b, 表示村庄a与b之间有一条道路(1 ≤ a, ...
- (64)zabbix正则表达式应用
概述 在前面的<zabbix low-level discovery>一文中有filter一项,用于从结果中筛选出你想要的结果,比如我们在filter中填入^ext|^reiserfs则表 ...
- Centos6.9 搭建rsync服务端与客户端 案例:全网备份项目
rsync的企业工作场景说明 1)定时备份 1.1生产场景集群架构服务器备份方案项目 借助cron+rsync把所有客户服务器数据同步到备份服务器 2)实时复制 本地数据传输模式(local-only ...
- memory bist lib
model NVIC_REG6T_1024x32(resetb,margin,clk,en,we,addr,d,q) ( bist_definition( clock clk high; chip_e ...
- 【支付宝支付】扫码付和app支付,回调验证签名失败问题
在检查了参数排序,编码解码,文件编码等问题后,发现还是签名失败,最后找出原因: 扫码付和app支付采用的支付宝公钥不一样 Pid和公钥管理里面: 开放平台密钥界面和开放平台应用界面的密钥应该一 ...