A - Marineking wilyin

Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others)
Submit Status

There are three marines in wilyin's base. Their positions form a right triangle.Now wilyin get another marine,he want to put it on some place to form a rectangle with the former three marines.where should he put it on?

Input

The first line of the input contains an integer T which means the number of test cases. Then T lines follow, each line consists of 6 positive integers x1,y1,x2,y2,x3,y3 which means the positions of these three marines.

You may assume the absolute value of coordinate not exceed 3000.

Output

For each case, print the coordinate of the forth marine on a single line.

Sample input and output

Sample Input Sample Output
2
0 0 1 0 0 1
0 1 0 -1 1 0
1 1
-1 0
#include <iostream>
#include <cstring>
#include <cstdio> #include <queue>
#include <stack>
#include <cmath>
using namespace std;
int main()
{
#ifdef CDZSC_OFFLINE
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif int n;
scanf("%d",&n);
while (n--)
{
int a[3][2];
for(int i=0;i<3;i++)
{
for(int j=0;j<2;j++)
{
scanf("%d",&a[i][j]);
}
}
for(int i=0;i<3;i++)
{
int x=(a[i][1]-a[(i+1)%3][1])*(a[i][1]-a[(i+1)%3][1])+(a[i][0]-a[(i+1)%3][0])*(a[i][0]-a[(i+1)%3][0]);
int y=(a[i][1]-a[(i+2)%3][1])*(a[i][1]-a[(i+2)%3][1])+(a[i][0]-a[(i+2)%3][0])*(a[i][0]-a[(i+2)%3][0]);
int z=(a[(i+1)%3][1]-a[(i+2)%3][1])*(a[(i+1)%3][1]-a[(i+2)%3][1])+(a[(i+1)%3][0]-a[(i+2)%3][0])*(a[(i+1)%3][0]-a[(i+2)%3][0]);
if(x+y==z)//寻找直角点
{
swap(a[i][0],a[2][0]);
swap(a[i][1],a[2][1]);
break; }
}
printf("%d ",a[1][0]+a[0][0]-a[2][0]);
printf("%d\n",a[1][1]+a[0][1]-a[2][1]);
}
}
 

Marineking wilyin的更多相关文章

随机推荐

  1. UIwebView的html字符串高度计算

    ) { webView = [[UIWebView alloc]initWithFrame:CGRectMake(, , DEVW-, webviewH)]; webView.delegate = s ...

  2. C# using垃圾回收详解

    简介 定义一个范围,将在此范围之外释放一个或多个对象. 语法 using (Font font1 = new Font("Arial", 10.0f)) { } C# 语言参考 主 ...

  3. (转) Functions

    Functions Functions allow to structure programs in segments of code to perform individual tasks. In ...

  4. CSS布局部分知识总结

    一 切图 通过一个周的切图练习,我发现只有亲自动手后才能通过问题不断加深技术,要熟练掌握HTML页面编写时候时PHOTOSHOP操作. 以下一些知识点在网络布局时也是很重要的. 1.ul标签在谷歌.火 ...

  5. windows下配置Nginx+Mysql+Php7

    环境:Windows10 mysql-5.6.24-win32解压缩版    nginx-1.8.0    php7 1.Mysql安装 下载压缩文件之后解压缩至相应目录(我的目录是G:\wnmp\m ...

  6. img元素高度多出来的几像素

    HTML: <div class="test"><img src="body2.jpg" alt=""></d ...

  7. WordPress插件制作笔记(二)---Second Plugins Demo

    1->插件演示代码:下载地址:http://pan.baidu.com/s/1gd1lFlL 在 wordpress/wp-content/plugins/ 目录下 新建一个文件夹取名为seco ...

  8. pm2安装及常用命令

    安装:npm install -g pm2 启动程序:pm2 start <app_name|id|all> 列举进程:pm2 list 退出程序:pm2 stop <app_nam ...

  9. Socket基础(一)

    OSI七层模型: 物理层:比特,数据链路层:帧,网络层:包,传输层及以上:报文.因为不用,不做详解. TCP/IP模型:这个常用,详解. 链路层:负责在两个相邻节点上线路上的无差错传输数据,以帧为单位 ...

  10. C# 委托2

    委托的定义: (1) 将方法作为变量使用的一种机制,就是将方法当作变量用(声明,赋值,传参)   (2) 将变量当作方法来用,首先就要去声明变量,就要考虑变量的类型,就是(委托变量,对应方法的返回值, ...