首页 > 其他 > 详细

Marineking wilyin

时间:2014-12-27 18:47:27      阅读:242      评论:0      收藏:0      [点我收藏+]

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 InputSample 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

原文:http://www.cnblogs.com/guofeng1022/p/4188702.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!