poj 1819 Disks

http://poj.org/problem?id=1819

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <cmath>
 4 #include <cstdlib>
 5 #include <algorithm>
 6 using namespace std;
 7 
 8 const double eps=1e-8;
 9 struct point
10 {
11     double x;
12     double y,r;
13 }pp[2000];
14 bool flag[2000];
15 int stack1[2000],n;
16 
17 int main()
18 {
19     while(scanf("%d",&n)!=EOF)
20     {
21         double x;
22         int p=0,i,last;
23         for(last=i=1; i<=n; i++){
24             flag[i]=true;
25             scanf("%lf",&pp[i].r);
26             int k=0;
27             pp[i].x=pp[i].y=pp[i].r;
28             for(int j=1; j<=p; j++)
29             {
30                 x=pp[stack1[j]].x+2*sqrt(pp[i].r*pp[stack1[j]].r);
31                 if(x-pp[i].x>eps)
32                 {
33                     pp[i].x=x;
34                     k=j;
35                 }
36             }
37             p=k;
38             stack1[++p]=i;
39             if(pp[i].x+pp[i].r-pp[last].x-pp[last].r>eps)
40             {
41                 last=i;
42             }
43         }
44         for(int i=1; i<=p; i++) flag[stack1[i]]=0;
45         for(int j=last+1; j<=n; j++)
46         {
47             flag[j]=true;
48         }
49         int num=0;
50         for(int i=1; i<=n; i++)
51         {
52             if(flag[i])
53             {
54                 num++;
55             }
56         }
57         printf("%d\n",num);
58         for(int i=1; i<=n; i++)
59         {
60             if(flag[i])
61             {
62                 printf("%d\n",i);
63             }
64         }
65     }
66     return 0;
67 }
View Code

 

转载于:https://www.cnblogs.com/fanminghui/p/3564084.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值