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 |
求诸位大牛们帮小弟看看 数据过了 为什么wa呢#include<stdio.h> #include<math.h> #include<iostream> #include<algorithm> using namespace std; struct node { double x; double y; } p[100000]; int cmp(node a,node b) { return a.x<b.x; } int main() { int n,d,a[100000],b[100000],po=0; while(scanf("%d%d",&n,&d)!=EOF &&(n||d)) { if(n!=0&&d!=0) {po++; int sum=1,i; for(i=0; i<n; i++) { scanf("%d%d",&a[i],&b[i]); p[i].x=a[i]-sqrt(d*d*1.00-b[i]*b[i]*1.00); p[i].y=a[i]+sqrt(d*d*1.00-b[i]*b[i]*1.00); } sort(p,p+n,cmp); double q=p[0].y; int u; for(u=1; u<n; u++) { if(p[u].y<q) q=p[u].y; else if(p[u].x>q) { sum++; q=p[u].y; } } printf("Case %d: %d\n\n",po,sum);} else break; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator