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 <iostream> #include<cmath> #include<algorithm> #include<stdio.h> using namespace std; struct dot { double x1; double x2; }radar[1009]; bool cmp(dot a,dot b) { return a.x1<b.x1; } int main() { freopen("in.txt","r",stdin); double s; int n,d,i; int j=0; int sum,flag; double dots[1009][2]; while(cin>>n>>d&&n+d>0) { flag=1;sum=1; if(d<0) flag=0; for(i=0;i<n;i++) cin>>dots[i][0]>>dots[i][1]; for(i=0;i<n;i++) if(dots[i][1]>d) flag=0; if(flag==0) { j++; cout<<"case "<<j<<": "<<"-1"<<endl; continue; } for(i=0;i<n;i++) { s=sqrt(d*d-dots[i][1]*dots[i][1]); radar[i].x1=dots[i][0]-s; radar[i].x2=dots[i][0]+s; } sort(radar,radar+n,cmp); for(flag=0,i=1;i<n;i++) { if(radar[flag].x2>=radar[i].x1) { if(radar[i].x2<=radar[flag].x2) flag=i; } if(radar[flag].x2<radar[i].x1) { flag=i; sum++; } } j++; cout<<"case "<<j<<": "<<sum<<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