Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

大哥们 大姐们 谁来帮我看看啊啊 !!!~~~~~~~~WHY WA?

Posted by leiwen at 2009-08-24 21:24:43 on Problem 1410
#include<iostream>
using namespace std;
struct point
{
	int x;
	int y;
};
bool fun1(point c,int l,point a,point b)
{
	double x;
	if(b.y!=a.y)
	{
		x=(double(b.x-a.x)*c.y-b.x*a.y+a.x*b.y)/(b.y-a.y);
		if((x-a.x)*(x-b.x)<=0&&x-c.x>=0&&x-c.x-l<=0)
			return true;
		else
			return false;
	}
	else
		if(b.y!=c.y)
			return false;
		else
			if((a.x>=c.x&&a.x<=c.x+l)||(b.x>=c.x&&b.x<=c.x+l))
				return true;
			else
				return false;
}
bool fun2(point c,int l,point a,point b)
{
	double y;
	if(b.x!=a.x)
	{
		y=(double(b.y-a.y)*c.x+b.x*a.y-a.x*b.y)/(b.x-a.x);
		if((y-a.y)*(y-b.y)<=0&&y-c.y>=0&&y-c.y-l<=0)
			return true;
		else
			return false;
	}
	else
		if(b.x!=c.x)
			return false;
		else
			if((a.y>=c.y&&a.y<=c.y+l)||(b.y>=c.y&&b.y<=c.y+l))
				return true;
			else
				return false;
}
int main()
{
	int n;
	point a,b,c,d,e,f,g,h;
	bool flag;
	cin>>n;
	while(n--)
	{
		cin>>e.x>>e.y>>f.x>>f.y>>g.x>>g.y>>h.x>>h.y;
		a.x=g.x<h.x?g.x:h.x;
		a.y=g.y>h.y?g.y:h.y;
		d.x=g.x>h.x?g.x:h.x;
		d.y=g.y<h.y?g.y:h.y;
		b.x=d.x;
		b.y=a.y;
		c.x=a.x;
		c.y=d.y;
		flag=false;
		if(fun1(a,d.x-a.x,e,f))
			flag=true;
		else
			if(fun1(c,d.x-c.x,e,f))
				flag=true;
			else
				if(fun2(c,b.y-c.y,e,f))
					flag=true;
				else
					if(fun2(d,b.y-c.y,e,f))
						flag=true;
		if(e.x>c.x&&e.x<d.x&&f.x>c.x&&f.x<d.x&&e.y>c.y&&e.y<a.y&&f.y>c.y&&f.y<a.y)
			flag=true;
		if(flag==true)
			cout<<'T'<<endl;
		else
			cout<<'F'<<endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator