标签:
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 59563 | Accepted: 13430 |
Description
Input
Output
Sample Input
3 2 1 2 -3 1 2 1 1 2 0 2 0 0
Sample Output
Case 1: 2 Case 2: 1
Source
#include <iostream> #include <algorithm> #include <cmath> #include <cstdio> using namespace std; #define N 1010 struct P { double x1,x2; bool operator < (const P &t)const { if(x2!=t.x2) return x2<t.x2; return x1>t.x1; } }p[N]; int main() { int n,r; int iCase=1; int end_flag; while(scanf("%d%d",&n,&r),n||r) { end_flag=0; for(int i=1;i<=n;i++) { double x,y; scanf("%lf%lf",&x,&y); if(y>r) end_flag=1; p[i].x1=x-sqrt(r*r-y*y); p[i].x2=x+sqrt(r*r-y*y); } printf("Case %d: ",iCase++); if(end_flag) { printf("-1\n"); continue; } sort(p+1,p+n+1); int cnt=1; double tmp=p[1].x2; for(int i=2;i<=n;i++) { if(p[i].x1>tmp) { cnt++; tmp=p[i].x2; } } printf("%d\n",cnt); } return 0; }
标签:
原文地址:http://www.cnblogs.com/hate13/p/4548059.html