Time Limit: 3000MS | Memory Limit: 65536K | |
Total Submissions: 4189 | Accepted: 1501 |
Description
Input
Output
Sample Input
5 1 1 4 2 2 3 3 1 1 -2.0 8 4 1 4 8 2 3 3 6 -2.0 3 0 0 1 1 1 0 2 1 2 0 3 1 0
Sample Output
Top sticks: 2, 4, 5. Top sticks: 1, 2, 3.
Hint
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 4260 | Accepted: 2049 |
Description
Input
Output
Sample Input
5 0 0 4 4 0 4 4 0 5 0 7 6 1 0 2 3 5 0 7 6 3 -6 4 -3 2 0 2 27 1 5 18 5 0 3 4 0 1 2 2 5
Sample Output
INTERSECTING LINES OUTPUT POINT 2.00 2.00 NONE LINE POINT 2.00 5.00 POINT 1.07 2.20 END OF OUTPUT
/*************************************
璁$畻鍑犱綍鍩虹棰橈紝鍒ゆ柇鐩寸嚎鐩鎬氦鍙婃眰浜ょ偣
娉ㄦ剰鏂滅巼涓嶅瓨鍦ㄧ殑鎯呭喌
**************************************/
#include <iostream>
#include <cstdio>
int main()
{
double x1, y1, x2, y2, x3, y3, x4, y4;
int n;
double k1, k2;
double b1, b2;
double i_x, i_y;
scanf("%d", &n);
std::cout << "INTERSECTING LINES OUTPUT" << std::endl;
while( n-- )
{
scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
if( x1 != x2 && x3 != x4 )
{
k1 = ( y2 - y1 ) / ( x2 - x1 );
k2 = ( y4 - y3 ) / ( x4 - x3 );
b1 = y1 - k1 * x1;
b2 = y3 - k2 * x3;
if( k1 == k2 )
{
if( b1 == b2 )
printf("LINE\n");
else
printf("NONE\n");
}
else
{
i_x = (b2 - b1) / (k1 - k2);
i_y = k1 * i_x + b1;
printf("POINT %.2lf %.2lf\n", i_x, i_y);
}
}
else if( x1 == x2 && x3 == x4 )
{
if( x1 == x3 )
std::cout << "LINE\n";
else
std::cout << "NONE\n";
}
else if( x1 == x2 && x3 != x4 )
{
k2 = ( y4 - y3 ) / ( x4 - x3 );
b2 = y3 - k2 * x3;
i_x = x1;
i_y = k2 * x1 + b2;
printf("POINT %.2lf %.2lf\n", i_x, i_y);
}
else
{
k1 = ( y2 - y1 ) / ( x2 - x1 );
b1 = y1 - k1 * x1;
i_x = x3;
i_y = k1 * x3 + b1;
printf("POINT %.2lf %.2lf\n", i_x, i_y);
}
}
std::cout << "END OF OUTPUT\n";
return 0;
}