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

Re:帮忙啊,坚强的wa中

Posted by ning at 2006-04-25 21:27:16 on Problem 2074
In Reply To:帮忙啊,坚强的wa中 Posted by:ning at 2006-04-15 10:34:43
> //pku2074.cpp
> //wa中
> #include<stdio.h>
> #include<math.h>
> #include<stdlib.h>
> 
> #define N 5000
> typedef struct _OBJ
> {
> 	double x1,x2,y;
> }OBJ;
> typedef struct _POINT
> {
> 	double x,y;
> }POINT;
> POINT array[N];
> int pp;
> double fmax(double a,double  b)
> {
> 	return a>b?a:b;
> }
> double ShadowPoint (POINT p1,POINT p2,double y0)//p1 为上面点,p2 为下面 y0为property 的Y 
> {
> 	return p2.x-(p1.x-p2.x)*(p2.y-y0)/(p1.y-p2.y);
> }
> void Shadow(OBJ H,OBJ A,OBJ PROP)
> {
> 	POINT p1,p2;
> 	if(H.y>A.y&&A.y>PROP.y)
> 	{
> 		p1.x=H.x2,p1.y=H.y;
> 		p2.x=A.x1,p2.y=A.y;
> 		array[pp].x=ShadowPoint (p1,p2,PROP.y);//求左端点
> 		p1.x=H.x1,p1.y=H.y;
> 		p2.x=A.x2,p2.y=A.y;	
> 		array[pp].y=ShadowPoint (p1,p2,PROP.y);
> 		pp++;
> 	}
> 
> }
> int Cmp(const void *a,const void *b)
> {
> 	return ( (POINT *)a)->x-( (POINT *)b)->x>0;
> }
> int main()
> {
> 	OBJ h,a,prop;
> 	int n,ii;
> 	double ans,lasty,tmp;
> 	for(;scanf("%lf%lf%lf",&h.x1,&h.x2,&h.y);)
> 	{
> 		if(h.x1==0.&&h.x2==0.&&h.y==0.)
> 			break;
> 		scanf("%lf%lf%lf%d",&prop.x1,&prop.x2,&prop.y,&n);
> 		if(!n)
> 		{
> 			printf("%lf\n",prop.x2-prop.x1);
> 			continue;
> 		}
> 		for(pp=0;n--;)
> 		{
> 			scanf("%lf%lf%lf",&a.x1,&a.x2,&a.y);
> 			Shadow(h,a,prop);
> 		}
> 		qsort(array,pp,sizeof(array[0]),Cmp);//按x1有序。
> 		ans=array[0].x-prop.x1,lasty=prop.x1;
> 		for(ii=0;ii<pp;ii++)
> 		{
> 			if(array[ii].x>lasty)
> 			{
> 				tmp=array[ii].x-lasty;
> 				ans=fmax(ans,tmp);
> 				lasty=array[ii].y;
> 			}
> 			if(array[ii].y>lasty)
> 				lasty=array[ii].y;
> 			/*
> 			if(array[ii-1].y>prop.x2)
> 				array[ii-1].y=prop.x2;
> 			
> 			tmp=array[ii].x-array[ii-1].y;
> 			ans=fmax(ans,tmp);
> 			*/
> 		}
> 		ans=fmax(ans,prop.x2-lasty);
> 		if(ans<=.000000000001)
> 			printf("No View\n");
> 		else 
> 			printf("%.2lf\n",ans);
> 				
> 	}
> 	return 0;
> }
> /*
> 2 6 6
> 0 15 0
> 3
> 12 13 1
> 2.5 4 1
> 1 2 1
> 
> 2 6 6
> 0 15 0
> 4
> 12 13 1
> 1 15 5
> 3 4 1
> 1 2 1
> 
> 1 5 5
> 0 10 0
> 1
> 0 15 1
> 0 0 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