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的更多相关文章
随机推荐
- iOS-设计模式之代理反向传值
代理设计模式就是自己的方法自己不实现,让代理对象去实现. 可以让多个类实现一组方法. 委托模式的好处在于: 1.避免子类化带来的过多的子类以及子类与父类的耦合 2.通过委托传递消息机制实现分层解耦 代 ...
- Win8.1系统下安装nodeJS
Nodejs简介 Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境.Node.js 使用了一个事件驱动.非阻塞式 I/O 的模型,使其轻量又高效.Node.js ...
- 复数类(C++练习一)
写一个复数类,实现基本的运算,目的熟悉封装与数据抽象. 类的定义 #include <iostream> #include <vector> using namespace s ...
- (转) 学习C++ -> 引用( References )
学习C++ -> 引用( References ) 一.引用的介绍 引用就是某一变量(目标)的一个别名, 相当于同一个人有了两个名字, 无论喊哪一个名字实际上都是指的同一个人. 同样, 在 ...
- 豆瓣FM duilib版
最近duilib项目被复制到了github上,仿佛又多了些活力.想要总结以前的项目的同时因为很喜欢豆瓣的FM,所以打算做个duilib版本豆瓣FM. 在网上了看到了很多豆瓣的不同版本,node.js. ...
- Tango_with_django_17笔记
1. 在update Category tabole with SlugField中,起因是url会将空格自动转换成%20,为了把url变得美观,易读,可以用slugify,它可以把空格替换为连字符( ...
- Tomcat学习笔记 - 错误日志 - Tomcat安装版安装后第二次启动后闪退(转)-- javac不是内部或外部命令 -- 配置java环境教程
如果安装成功并且安装完成第一次启动是成功的,第二次就闪退的话,原因之一是没有配置java的环境.在网上找的配制方法有很多错误,测试javac命令时候会提示不是内部或外部命令,找到一个正确的教程.如下, ...
- 新手必看的jQuery优化笔记十则
jQuery优化 1.简介 jQuery正在成为Web开发人员首选的JavaScript库,作为Web开发者,除了要了解语言和框架的应用技巧外,如何提升语言本身的性能也是开发人员应该思考的问题.文章就 ...
- Array类型(二)
1.concat()方法可以基于当前数组中的所有项创建一个新数组. 先创建当前数组的一个副本,然后将接收到的参数添加到这个副本的末尾,最后返回新构建的数组. var colors = ["r ...
- 解决Webservice内存溢出-用XmlWriter
XmlWriter 表示一个编写器,该编写器提供一种快速.非缓存和只进的方式来生成包含 XML 数据的流或文件.这个就可以不占用内存,将数据放入磁盘中.也就不会出现内存溢出 public class ...