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 |
用二分做的,老是w,是不是输出格式的错误啊,请大牛找找,谢谢了。#include <iostream> using namespace std; __int64 a[5050],b[5050],box[5050]; int main() { int n; __int64 m,d,u,r,l; int i,j; __int64 x,y; __int64 h; __int64 lef,rig; while(1){ scanf("%d",&n); if(n==0)break; scanf("%I64d%I64d%I64d%I64d%I64d",&m,&d,&u,&r,&l);h=u-d; //输入隔离边 a[0]=l;b[0]=l; memset(box,0,sizeof(box)); for(i=1;i<=n;i++) scanf("%I64d%I64d",&a[i],&b[i]); a[n+1]=r;b[n+1]=r; //输入玩具位置。用二分求位置 for(i=1;i<=m;i++){ scanf("%I64d%I64d",&x,&y); lef=0;rig=n+1; while(lef+1<rig){ j=(rig+lef)/2; if(a[j]!=b[j]&&(x-b[j])*h<(y-l+0.0)*(a[j]-b[j])){rig=j;} else if(a[j]==b[j]&&x<a[j]){rig=j;}//斜率不存在。 else lef=j; } //记录盒子放的东西数目。 rig--; box[rig]++; } //输出 for(i=0;i<=n;i++){ printf("%d: %d\n",i,box[i]); } cout<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator