首页 > 代码库 > Marineking wilyin
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 |
---|---|
20 0 1 0 0 10 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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。