Marineking wilyin
A - Marineking wilyin
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)
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 |
1 1 |
#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的更多相关文章
随机推荐
- Java实现的 线程池
由于最近开始学习java,用到了线程池,按照之前c++的写法写出此java版的线程池 TaskRunnale实现相关任务的接口,具体要实现什么任务在相应的run函数中实现. package threa ...
- [置顶] 【C/C++学习】之十三、虚函数剖析
所谓虚函数,虚就虚在“推迟联编”或者“动态联编”上,一个类函数的调用并不是在编译时刻被确定的,而是在运行时刻被确定的.由于编写代码的时候并不能确定被调用的是基类的函数还是哪个派生类的函数,所以被称为“ ...
- grep;egrep;fgrep
-1 使用场景:搜索定位内容并输出(所在行) -2 三者区别: --1 grep 默认支持普通正则 --2 egrep 默认支持扩展正则 等同于 grep -E --3 fgrep 速度最快,不支持 ...
- [TYVJ] P1030 乳草的入侵
乳草的入侵 背景 Background USACO OCT09 6TH 描述 Description Farmer John一直努力让他的草地充满鲜美多汁的而又健康的牧草.可惜天不从人愿,他在植物 ...
- 汇编写函数:关于PUBLIC和EXTRN的区别
PUBLIC伪指令的格式:PUBLIC 标识符,标识符... 该伪指令告诉汇编程序放在PUBLIC之后的标识符(本模块的定义的)可为其他模块使用,这些标识符可以是变量.标号或者过程名.言外之意,它不仅 ...
- VCL线程的同步方法 Synchronize(用消息来同步)
看本文时,可以同时参考:Delphi中线程类 TThread实现多线程编程(事件.临界区.Synchronize.WaitFor……) 先说一下RTL和VCL RTL(Run-Time library ...
- 在 ASP.NET MVC 项目中使用 WebForm、 HTML
原文地址:http://www.cnblogs.com/snowdream/archive/2009/04/17/winforms-in-mvc.html ASP.NET MVC和WebForm各有各 ...
- Best Time to Buy and Sell Stock II 解答
Question Say you have an array for which the ith element is the price of a given stock on day i. Des ...
- python刷取CSDN博文访问量之二
python刷取CSDN博文访问量之二 作者:vpoet 注:这个系列我只贴代码,代码不注释.有兴趣的自己读读就懂了,纯属娱乐,望管理员抬手 若有转载一定不要注明来源 #coding=utf ...
- POJ3026(BFS + prim)
Borg Maze Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10554 Accepted: 3501 Descri ...