博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
第四届 Rescue The Princess
阅读量:5260 次
发布时间:2019-06-14

本文共 2560 字,大约阅读时间需要 8 分钟。

 

Description

Several days ago, a beast caught a beautiful princess and the princess was put in prison. To rescue the princess, a prince who wanted to marry  the princess set out immediately. Yet, the beast set a maze. Only if the prince find out the maze’s exit can he save the princess.

Now, here comes the problem. The maze is a dimensional plane. The beast is smart, and he hidden the princess snugly. He marked two coordinates of an equilateral triangle in the maze. The two marked coordinates are A(x1,y1) and B(x2,y2). The third coordinate C(x3,y3) is the maze’s exit. If the prince can find out the exit, he can save the princess. After the prince comes into the maze, he finds out the A(x1,y1) and B(x2,y2), but he doesn’t know where the C(x3,y3) is. The prince need your help. Can you calculate the C(x3,y3) and tell him?

Input

The first line is an integer T(1 <= T <= 100) which is the number of test cases. T test cases follow. Each test case contains two coordinates A(x1,y1) and B(x2,y2), described by four floating-point numbers x1, y1, x2, y2 ( |x1|, |y1|, |x2|, |y2| <= 1000.0). 

        Please notice that A(x1,y1) and B(x2,y2) and C(x3,y3) are in an anticlockwise direction from the equilateral triangle. And coordinates A(x1,y1) and B(x2,y2) are given by anticlockwise.

Output

For each test case, you should output the coordinate of C(x3,y3), the result should be rounded to 2 decimal places in a line.

Sample Input

4-100.00 0.00 0.00 0.000.00 0.00 0.00 100.000.00 0.00 100.00 100.001.00 0.00 1.866 0.50

Sample Output

(-50.00,86.60)(-86.60,50.00)(-36.60,136.60)(1.00,1.00)
#include 
#include
#include
#include
#include
#include
using namespace std;struct Point{ double x,y; Point(){} Point(double x,double y):x(x),y(y){}};Point operator + (Point A,Point B)//向量+向量=向量,点+向量=点{ return Point(A.x+B.x,A.y+B.y);}Point operator - (Point A,Point B)//向量+向量=向量,点+向量=点{ return Point(A.x-B.x,A.y-B.y);}Point operator * (Point A,double p)//向量+向量=向量,点+向量=点{ return Point(A.x*p,A.y*p);}double Dot(Point A,Point B){ return A.x*B.x+A.y*B.y;}double Length(Point A){ return sqrt(Dot(A,A));}Point Normal(Point A){ double L=Length(A); return Point(-A.y/L,A.x/L);}int main(){ int T; cin>>T; while(T--) { Point A,B,C; cin>>A.x>>A.y>>B.x>>B.y; C.x=(A.x+B.x)/2; C.y=(A.y+B.y)/2; Point v=Normal(Point(B.x-A.x,B.y-A.y)); double len=Length(Point(B.x-A.x,B.y-A.y)); double len1=sqrt(len*len-len*len/4); C=C+v*len1; cout<
<

转载于:https://www.cnblogs.com/MisdomTianYa/p/6581750.html

你可能感兴趣的文章
CF1215E Marbles
查看>>
手把手教你写一个windows服务 【基于.net】 附实用小工具{注册服务/开启服务/停止服务/删除服务}...
查看>>
.net Core 图片验证码 基于SkiaSharp实现
查看>>
fish redux 个人理解
查看>>
java 笔记一些
查看>>
java面象对向整理
查看>>
mybatis整理笔记
查看>>
java工作记录
查看>>
Find Method Sign Line Number
查看>>
[Oracle123] Sequence 序列号
查看>>
【XML123】了解XMLUnit
查看>>
【Java123】ThreadLocal学习笔记
查看>>
[ORACLE123] sysdate处理
查看>>
Linux进程实时可视化监控
查看>>
[Java123] 开源工具guava比较器链ComparisonChain (附加比较null空值的实现方法)
查看>>
[Java123] Java的异常处理机制
查看>>
[Java123] 方法重载中遇到的编译器错误: both methods have same erasure => 引入Java泛型type erasure...
查看>>
[Java123] HashMap实现和应用
查看>>
[Oracle123] DROP TABLE、TRUNCATE TABLE、DELETE DATA
查看>>
[Java123] 认识JavaBean
查看>>