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的更多相关文章
随机推荐
- javaScript动态添加样式
[动态添加css样式] <html> <head> <script type="text/javascript"> window.onload= ...
- (原)ubuntu上安装nvidia及torch的nccl
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5717234.html 参考网址: https://github.com/NVIDIA/nccl htt ...
- Draw2d中的布局管理器Layout比较
最近在研究Eclipse中的GEF开发,在跟着GEF-whole-upload教程做一个GEF应用程序的例子时,发现Figure上的控件无法显示,谷歌了很久也没找到解决方案,最后终于发现是Layout ...
- yii2 打印sql语句
echo $temp_chat_query->createCommand()->getRawSql();
- PK投票效果
/** *createTime:2015-07-21 *updateTime:2015-06-22 *author:刘俊 *Description:PK投票 *phone:13469119119 ** ...
- DOM2定位与高宽类属性专题学习【DOM专题学习系列(一)】
网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可见区域宽: document.body.offset ...
- UML中九种图的理解
1.用例图. 用例图是用来描述用户需求的,从用户的角度来描述系统的功能,并指出各个执行者.强调谁在使用,系统的执行者是谁. 2.类图. 用来定义系统中的类,包括描述类的结构和类之间的关系.类图的主要作 ...
- POJ3026 最小生成树
问题: POJ3026 分析: 采用BFS算出两两之间的距离,再用PRIM算法计算最小生成树. AC代码: //Memory: 220K Time: 32MS #include <iostrea ...
- oracle安装报错检查操作系统版本: 必须是5.1 or 5.2。实际为 6.1未通过
oracle安装时报错,提示:操作系统版本: 必须是5.1 or 5.2.实际为 6.1未通过 , 解决方案 这里只认证5.1.5.2的OS版本,但是我的win server 2008系统版本为6.1 ...
- web容器 - Jetty
详解web容器 - Jetty与Tomcat孰强孰弱 Jetty 基本架构 Jetty目前的是一个比较被看好的 Servlet 引擎,它的架构比较简单,也是一个可扩展性和非常灵活的应用服务器. 它 ...