标签: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 }
标签:open play 分享 sum bsp 技术 asi std bool
原文地址:https://www.cnblogs.com/ghcred/p/9278393.html