Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
水果#include <iostream> #include <stdio.h> #include <algorithm> #include <cmath> using namespace std; const double PI = 3.1415926535898; const double EPSILON = 1e-15; int main() { int num; scanf("%d", &num); int bc[110]; for(int i = 0; i < num; i++) scanf("%d", &bc[i]); sort(bc, bc+num); int sum = 0; for(int i = 0; i < num-1; i++){ sum += bc[i]; } if(sum <= bc[num-1]){ printf("0.00\n"); return 0; } double r = bc[num-1] * 0.5; double s = 0; for(int i = 0; i < num-1; i++) s += asin(bc[i]/2.0/r); if(abs(s-PI/2) < EPSILON) { //圆心在最大边上 double area = 0; for(int i = 0; i < num-1; i++) area += (bc[i]*0.5)*sqrt(r*r-bc[i]*bc[i]/4.0); printf("%.2lf\n", area); } else if(s > PI/2){ //圆心在内部 while(1){ r *= 2; double ss = 0; for(int i = 0; i < num; i++) ss += asin(bc[i]/2.0/r); if(ss < PI - EPSILON) break; } double low = r/2, up = r, R; bool zdl = 0; while(up - low > 1e-10){ double mid = (low + up)/2; double ss = 0; for(int i = 0; i < num; i++) ss += asin(bc[i]/2.0/mid); if(abs(ss - PI) < EPSILON){ zdl = 1; R = mid; break; } if(ss > PI) low = mid; else up = mid; } if(!zdl) R = (low + up)/2; double area = 0; for(int i = 0; i < num; i++) area += (bc[i]*0.5)*sqrt(R*R-bc[i]*bc[i]/4.0); printf("%.2lf\n", area); } else{ //圆心在外部 while(1){ r *= 2; double sum = 0; for(int i = 0; i < num-1; i++) sum += asin(bc[i]/2.0/r); sum -= asin(bc[num-1]/2.0/r); if(sum > EPSILON) break; } double low = r/2, up = r, R; bool zdl = 0; while(up - low > 1e-10){ double mid = (up + low)/2; double ss = 0; for(int i = 0; i < num-1; i++) ss += asin(bc[i]/2.0/mid); ss -= asin(bc[num-1]/2.0/mid); if(abs(ss) < EPSILON){ zdl = 1; R = mid; //printf("1"); break; } if(ss > 0) up = mid; else low = mid; } if(!zdl) R = (up + low)/2; //double ck = 0; //for(int i = 0; i < num-1; i++) ck += asin(bc[i]/2.0/R); //ck -= asin(bc[num-1]/2.0/R); //printf("%.16lf\n", ck); double area = 0; for(int i = 0; i < num-1; i++) area += (bc[i]*0.5)*sqrt(R*R-bc[i]*bc[i]/4.0); area -= (bc[num-1]*0.5)*sqrt(R*R-bc[num-1]*bc[num-1]/4.0); printf("%.2lf\n", area); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator