hoj 13911 Squeeze the Cylinders

//喜欢如此简单的代码 但是我却如此的蠢
#include #include #include #include <set> #include #include #include <string.h> #include #include #include #define LL long long #define INF 2100000000 #define fi first #define se second #define lowbit(x) (x&(-x)) #define eps 5e-7 #define getr(x,y) x*y/(x+y+2.0*sqrt(x*y)) #define getd(x,y) 2.0*sqrt(x*y) #define judgel(r,x) r+sqrt(2*x*r+r*r)<=x using namespace std; const int maxn=(int)1e6 +10; const LL MOD=(LL)1e9+7; int n; double r[maxn]; double x[maxn]; int main(){ #ifdef shuaishuai freopen("C:\\Users\\hasee\\Desktop\\a.txt","r",stdin); //freopen("C:\\Users\\hasee\\Desktop\\b.txt","w",stdout); #endif scanf("%d",&n); for(int i=0;i"%lf",r+i); if(n==1){printf("%.6lf\n",2*r[0]);return 0;} x[0]=0; double ll = -r[0],rr=r[0]; for(int i=1;i){ double p=0; for(int j=i-1;j>=0;j--){ p=max(p,x[j]+getd(r[i],r[j])); } x[i]=p; ll=min(ll,x[i]-r[i]); rr=max(rr,x[i]+r[i]); } // for(int i=0;i// printf("%d %.3lf\n",i,x[i]); printf("%.6lf\n",rr-ll); return 0; }

 

转载于:https://www.cnblogs.com/MeowMeowMeow/p/7442930.html

你可能感兴趣的:(hoj 13911 Squeeze the Cylinders)