码迷,mamicode.com
首页 > 其他好文 > 详细

综合-学长杂题讲义

时间:2018-07-07 22:37:12      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:open   play   分享   sum   bsp   技术   asi   std   bool   

1.

Rasheda And The Zeriba

大致题意: 给出n条边,判断能否构成一个n边凸多边形,并求出能覆盖该图形的圆的最小半径 1 ≤ n ≤ 1000

http://codeforces.com/gym/100283/problem/A 

技术分享图片
 1 #include <cstdio>
 2 #include <cmath>
 3 #include <algorithm>
 4 
 5 using namespace std;
 6 
 7 int N;
 8 double R[1005];
 9 const double _pi = asin(1)*2;
10 
11 bool Check(double v)
12 {
13     double tmp = 0; int i;
14     for (i = 1; i <= N; ++i)
15         if ((tmp += asin(R[i]/2/v)*2) > 2*_pi) break;
16     return i == N+1;
17 }
18 
19 int main()
20 {
21     freopen("zeriba.in", "r", stdin);
22     int T;
23     scanf("%d", &T);
24     for (int ca = 1; ca <= T; ++ca) {
25         scanf("%d", &N);
26         double sum = 0, mx = 0; int i;
27         for (i = 1; i <= N; ++i)
28             scanf("%lf", &R[i]), sum += R[i], mx = max(mx, R[i]);
29         for (i = 1; i <= N; ++i)
30             if (sum-R[i] <= R[i]) break;
31         if (i != N+1) { printf("Case %d: can‘t form a convex polygon\n", ca); continue; }
32         double l = mx/2, r = sum/4;
33         while (fabs(l-r) >= 0.000001) {
34             double mid = (l+r)/2;
35             if (Check(mid)) r = mid;
36             else l = mid;
37         }
38         printf("Case %d: %.4lf\n", ca, l);
39     }
40     return 0;
41 }
View Code

 

综合-学长杂题讲义

标签:open   play   分享   sum   bsp   技术   asi   std   bool   

原文地址:https://www.cnblogs.com/ghcred/p/9278393.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!