Follows 191.c (Total 67 lines):

/* @JUDGE_ID:4461XX 191 C */
/* A */
#include<stdio.h>
double xstar , ystar , xend , yend , a , b , c ;
int check( double x1 , double y1 , double x2 , double y2 )
{
	double s , t , r ;
	/* sx+ty+r */
	if( x1 == x2 ){
		s = 1.0 ;
		t = 0.0 ;
		r = -x1 ;
	}
	else{
		s = 0.0 ;
		t = 1.0 ;
		r = -y1 ;
	}
	if( (a*x1+b*y1+c)*(a*x2+b*y2+c) < 0 &&
		 (s*xstar+t*ystar+r)*(s*xend+t*yend+r) <= 0 ) return 1 ;
	else if( (a*x1+b*y1+c)*(a*x2+b*y2+c) == 0 &&
				(s*xstar+t*ystar+r)*(s*xend+t*yend+r) < 0 ) return 1 ;
	else if( (a*x1+b*y1+c)*(a*x2+b*y2+c) == 0 &&
				(s*xstar+t*ystar+r)*(s*xend+t*yend+r) == 0 ){
		if( x1 == x2 )
			if( ( y1<=ystar && ystar<=y2 ) || ( y1<=yend && yend<=y2 ) ) return 1 ;
			else return 0 ;
		else
			if( ( x1<=xstar && xstar<=x2 ) || ( x1<=xend && xend<=x2 ) ) return 1 ;
			else return 0 ;
	}
	else return 0 ;
}
void swap( double *a , double *b )
{
	double temp ;
	temp = *a ;
	*a = *b ;
	*b = temp ;
}
void main( void )
{
	double time , xleft , ytop , xright , ybottom , yes ;
	/* ax+by+c */
/*	freopen( "C:\\windows\\desktop\\191.in" , "r" , stdin ) ;
	freopen( "C:\\windows\\desktop\\191.out" , "w" , stdout ) ;*/
	scanf( "%lf" , &time ) ;
	for( ; time ; time-- ){
		scanf( "%lf %lf %lf %lf %lf %lf %lf %lf" ,
				 &xstar , &ystar , &xend , ¥d ,
				 &xleft , &ytop , &xright , &ybottom ) ;
		if( xleft > xright ) swap( &xleft , &xright ) ;
		if( ybottom > ytop ) swap( &ytop , &ybottom ) ;
		a = yend - ystar ;
		b = xstar - xend ;
		c = ystar * xend - yend * xstar ;
		if( check( xleft , ybottom , xleft , ytop ) ||
			 check( xleft , ybottom , xright , ybottom ) ||
			 check( xright , ybottom , xright , ytop ) ||
			 check( xleft , ytop , xright , ytop ) ) printf( "T\n" ) ;
		else
			if( xleft<=xstar && xstar<=xright && xleft<=xend && xend<=xright &&
				 ybottom<=ystar && ystar<=ytop && ybottom<=yend && yend<=ytop )
				printf( "T\n" ) ;
			else printf( "F\n" ) ;
	}
}

Back to statistics
Ya-Lin Huang (C)
huangyl@gmail.com