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的更多相关文章

  1. 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 ...

  2. HDU 4348 SPOJ 11470 To the moon

    Vjudge题面 Time limit 2000 ms Memory limit 65536 kB OS Windows Source 2012 Multi-University Training C ...

  3. 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 ...

  4. 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) ...

  5. 2016 Multi-University Training Contests

    2016 Multi-University Training Contest 1 2016 Multi-University Training Contest 2 2016 Multi-Univers ...

  6. SPOJ DQUERY D-query(主席树)

    题目 Source http://www.spoj.com/problems/DQUERY/en/ Description Given a sequence of n numbers a1, a2, ...

  7. 2016 Multi-University Training Contest 2 D. Differencia

    Differencia Time Limit: 10000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  8. 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) ...

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

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

随机推荐

  1. sql server 2008怎么设置不允许windows身份验证

  2. React学习实例总结,包含yeoman安装、webpack构建

    1.安装yeoman 在安装nodeJs的基础上,输入命令:npm install -g yo grunt-cli bower,安装yeoman,grunt,bowerify 安装完成后,输入命令:y ...

  3. spark简单入门

    本文由cmd markdown编辑,原始链接:https://www.zybuluo.com/jewes/note/35032 RDD是什么? RDD是Spark中的抽象数据结构类型,任何数据在Spa ...

  4. idea 发布和本地测试问题

    1.maven本地打包成jar 提示[错误: 找不到或无法加载主类]修改 配置maven ---->Runner---->VM Optins [-DarchetypeCatalog=loc ...

  5. CPP-网络/通信:COM

    ))//打开串口 { ) { CloseCom();//关闭串口 break; } //添加处理代码. } //最后关闭串口 CloseCom();//关闭串口

  6. Codeforces Round #274 (Div. 2)-C. Exams

    http://codeforces.com/contest/479/problem/C C. Exams time limit per test 1 second memory limit per t ...

  7. shell脚本,创建50个文件,删除50个文件。

    [root@localhost ~]# cat create50.sh #!/bin/bash #创建50个文件 ` do touch student$i done echo "创建50个文 ...

  8. 人脸识别中的检测(在Opencv中加入了QT)

    #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include & ...

  9. grep-sed命令用法:

    用户切换 su username:非登录式切换 su - username:登录式切换 su -l username:登录式切换 su username -c COMMAND   echo -n   ...

  10. laravel中对加载进行优化

    在laravel中的模型与模型之间创建好关联关系会比较方便的方法 但是我们为了方便,有时也会忽略一些东西,比如: 我们在控制器中把整个一个文章对象传到了模板页面 在一次for循环下, 我们对数据进行了 ...