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

## 提交很多次总是wa，求指点

Posted by haining at 2012-07-07 10:45:22 on Problem 1066
```#include<iostream>
using namespace std;
#define zero 0.00000001

int n;
double xm,ym;

struct point{
int x1;
int y1;
int x2;
int y2;
}wall[40];
int side1[40];
int side2;

struct out{
int x;
int y;
}outer[40];

int main()
{   int x1,y1,n;
int a,b,c;
outer[0].x=0;
outer[0].y=0;
outer[1].x=0;
outer[1].y=100;
outer[2].x=100;
outer[2].y=0;
outer[3].x=100;
outer[3].y=100;
int sp=3;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d%d%d%d",&wall[i].x1,&wall[i].y1,&wall[i].x2,&wall[i].y2);
outer[++sp].x=wall[i].x1;
outer[sp].y=wall[i].y1;
outer[++sp].x=wall[i].x2;
outer[sp].y=wall[i].y2;
}
scanf("%lf%lf",&xm,&ym);
double s;
for(int i=0;i<n;i++)
{  a=wall[i].y2-wall[i].y1;
b=wall[i].x1-wall[i].x2;
c=wall[i].x2*wall[i].y1-wall[i].x1*wall[i].y2;
s=a*xm+b*ym+c;
if(s>zero) side1[i]=1;
else if(s<zero)side1[i]=-1;
else side1[i]=0;
}
int num;
int minn=9999;
for(int i=0;i<sp;i++)
for(int j=i+1;j<sp;j++)
{
x1=outer[i].x+outer[j].x;
y1=outer[i].y+outer[j].y;
if((x1==0)||(x1==200)||(y1==0)||(y1==200))
{  num=0;
for(int k=0;k<n;k++)
{
a=wall[k].y2-wall[k].y1;
b=wall[k].x1-wall[k].x2;
c=wall[k].x2*wall[k].y1-wall[k].x1*wall[k].y2;
if(a*x1+b*y1+2*c>zero)side2=1;
else if(a*x1+b*y1+2*c<zero)side2=-1;
else
{
num=9999;break;
}
if(side1[k]!=side2)num++;
}
if(num<minn)minn=num;
}
}

printf("Number of doors = %d\n",++minn);

// system("pause");
return 0;

}

```

Followed by: