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 <cstdio> #include <algorithm> #include <cmath> using namespace std; #define N 101 #define exp 10e-9 struct Ring{ float x; float y; float r; }ring[N]; int main() { int i,j,ans,num,n; double dist; while(scanf("%d",&n)&&n!=-1) { for(i=0; i<n; i++) scanf("%f %f %f",&ring[i].x,&ring[i].y,&ring[i].r); ans=0; for(i=0; i<n; i++) { num=0; for(j=0; j<n; j++) { if(fabs(ring[i].x-ring[j].x)<exp&&fabs(ring[i].y-ring[j].y)<exp&&fabs(ring[i].r-ring[j].r)<exp) { num++; continue; } dist=sqrt(pow(ring[i].x-ring[j].x,2)+pow(ring[i].y-ring[j].y,2)); if(dist>(double)fabs(ring[i].r-ring[j].r)&&dist<fabs(ring[i].r+ring[j].r)) num++; } if(num>ans) ans=num; } printf("The largest component contains %d rings\n",ans); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator