| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
一个continue害死我拉,贴一下代码吧,过了。一个continue害死我拉,贴一下代码吧,过了。
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
const double J=pow(10.0,-8.0);
struct point {
double x,y;
}p1[1001],p2[1001],b,e,p[1001];
double dis(point p1,point p2){
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
double multi(point a,point b ,point o ){
return (a.x-o.x)*(b.y-o.y)-(b.x-o.x)*(a.y-o.y);
}
int main(int argc, char *argv[])
{int ncases,i,j,k,n;
while(scanf("%d",&ncases)!=EOF){
while(ncases--){
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%lf%lf%lf%lf",&p1[i].x,&p1[i].y,&p2[i].x,&p2[i].y);
p[2*i]=p1[i];
p[2*i+1]=p2[i];
}
if(n==1||n==2)
printf("Yes!\n");
else {
bool pp;
bool yes=0;
for(i=0;i<2*n;i++){
for(j=0;j<2*n;j++){
pp=1;
b=p[i];
e=p[j];
if(dis(b,e)<J){
pp=0;
continue;
}
for(k=0;k<2*n;k+=2){
double x1,x2;
x1=multi(p[k],b,e);
x2=multi(p[k+1],b,e);
if(x1*x2>=J){
pp=0;
break;
}
}
if(pp)
break;
}
if(pp){
yes=1;
break;
}
}
if(yes)
printf("Yes!\n");
else
printf("No!\n");
}
}
}
system("PAUSE");
return EXIT_SUCCESS;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator