首页 > 其他 > 详细

POJ 1328

时间:2018-10-09 20:56:56      阅读:160      评论:0      收藏:0      [点我收藏+]
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cmath>
 4 #include <cstring>
 5 #include <algorithm>
 6 #include <queue>
 7 #include <stack>
 8 #include <vector>
 9 using namespace std;
10 struct node
11 {
12     double x,y;
13 };
14 bool cmp(const node &a,const node &b)
15 {
16     return a.y<b.y;
17 } 
18 int main(int argc, char *argv[])
19 {
20     int n,d;
21     int ans=0;
22     node a[1100];
23     while(scanf("%d%d",&n,&d)!=EOF)
24     {
25         ans++;
26         if(n==0&&d==0)
27         break;
28         int x,y;
29         double t;
30         int flag=0;
31         for(int i=0;i<n;i++)
32         {
33             scanf("%d%d",&x,&y);
34             if(y>d)
35                 flag=1;
36             t=sqrt(d*d*1.00-y*y*1.00);
37             a[i].x=x-t;a[i].y=x+t;
38         }
39         if(flag||d<0)
40         {
41             printf("Case %d: -1\n",ans);
42             continue;
43         }
44         sort(a,a+n,cmp);
45         t=a[0].y;
46         int sum=1;
47         for(int i=0;i<n;i++)
48         {
49             if(a[i].x>t)
50             {
51                 sum++;
52                 t=a[i].y;
53             }
54         }
55         printf("Case %d: %d\n",ans,sum);
56     }
57     return 0;
58 }

 

POJ 1328

原文:https://www.cnblogs.com/huluxin/p/9762747.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!