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

求大神看看哪错了!!!

Posted by shijiayin at 2013-04-25 20:54:49 on Problem 2318
#include<cstdio>
#include<cmath>
#include<cstring>
#ifdef unix
#define INT64 "%lld"
#else
#define INT64 "%I64d"
#endif
#define LL long long
using namespace std;
const double ep=1e-3;
int  n,m;
long long  a[5001],b[5001],x[5001],y[5001];
long long num[5001];
long long  xx,yy,yy1,yy2;
bool  zuo(long long l,long long p){
     yy=y[p];
     long long det11=(a[l]-b[l])*(yy-yy2)-(xx-b[l])*(yy1-yy2);
     long long  det22=(a[l]-b[l])*(y[p]-yy2)-(x[p]-b[l])*(yy1-yy2);
     if (det11*det22<ep) return true;
     return false;
}

void work(int x){
     int l=0;
     int r=n;
     while (l<=r){
	  int mid=(l+r)/2;
	  if (zuo(mid,x)) l=mid+1;
	  else r=mid-1;
     };
     ++num[r];

}


int main(){
       freopen("2318.in","r",stdin);
        freopen("2318.out","w",stdout);
     while(scanf("%d%d"INT64 INT64 INT64 INT64,&n,&m,&a[0],&yy1,&b[0],&yy2),n>0&&m>0){
	  for (int i=1;i<=n;++i){
	       scanf(INT64 INT64,&a[i],&b[i]);
	  };
	  b[0]=a[0];
	  xx=a[0]-1;
	  for (int i=1;i<=m;++i){
	       scanf(INT64 INT64,&x[i],&y[i]);
	  };
	  memset(num,0,sizeof(num));
	  for (int i=1;i<=m;++i){
	       work(i);
	  };
	  for (int i=0;i<=n;++i)printf("%d: "INT64"\n",i,num[i]);
	  printf("\n");
     }
}

	  
    
	       


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