zoukankan      html  css  js  c++  java
  • hoj 13911 Squeeze the Cylinders

    //喜欢如此简单的代码 但是我却如此的蠢
    #include <iostream> #include <algorithm> #include <stdio.h> #include <set> #include <queue> #include <limits.h> #include <string.h> #include <vector> #include <map> #include <math.h> #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<n;i++)scanf("%lf",r+i); if(n==1){printf("%.6lf ",2*r[0]);return 0;} x[0]=0; double ll = -r[0],rr=r[0]; for(int i=1;i<n;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<n;i++) // printf("%d %.3lf ",i,x[i]); printf("%.6lf ",rr-ll); return 0; }
  • 相关阅读:
    JS年月日三级联动下拉列表
    日志分析软件
    配置Smarty
    JS无刷新省市两级联动下拉列表
    graylog2+syslogng+mongodb构建集中管理日志服务器
    syslog及syslogng详解
    php+pdo实现分页类代码
    编程实践62
    编程实践65
    编程实践64
  • 原文地址:https://www.cnblogs.com/MeowMeowMeow/p/7442930.html
Copyright © 2011-2022 走看看