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 |
怎么就错了呢?谁有空帮忙看一看,谢谢!!!#include <iostream> #include <stdlib.h> #include <cmath> using namespace std; int main() { struct Data { double x,y; }data[1001]; int n,t=1; double d; while(cin>>n>>d,n || d) { int i,j; for(i=0;i<n;i++) { cin>>data[i].x>>data[i].y; } for(i=n-1;i>0;i--) { for(j=0;j<i;j++) { if(data[j].x>data[j+1].x) { Data tem=data[j+1]; data[j+1]=data[j]; data[j]=tem; } if(data[j].x==data[j+1].x && data[j].y<data[j+1].y) { Data tem=data[j+1]; data[j+1]=data[j]; data[j]=tem; } } } int cnt=1; double pos=sqrt(d*d-data[0].y*data[0].y)+data[0].x; for(i=1;i<n;i++) { if(data[i].y>d) {cnt=-1;break;} if((data[i].x-pos)*(data[i].x-pos)+data[i].y*data[i].y<=d*d) continue; else { pos=sqrt(d*d-data[i].y*data[i].y)+data[i].x; cnt++; } } if(n==0) cnt=0; cout<<"Case "<<t++<<": "<<cnt<<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