1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| #include<iostream> #include<cstdio> #include<cstring> #include<cctype> #include<algorithm> #include<cmath> #include<ctime> #define T 10000 #define eps 0.99 #define kb 1.38e-23 #define endt 1e-12 #define INF 1e19 using namespace std; inline int read(){ int w=0,x=0;char c=getchar(); while(!isdigit(c))w|=c=='-',c=getchar(); while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar(); return w?-x:x; } namespace star { const int maxn=45; int n1,n2,n3,d1,d2,n,a[maxn],m; double r1,r2,r3,res,ans; inline double getsum(){ double sum=0; for(int i=1;i<=n;i++){ if(a[i]!=3)continue; int x=i; if(x>m)x-=m; double L3=x-r3,R3=x+r3; for(int j=1;j<=n;j++){ if(a[j]==3)continue; int y=j,t=a[j]; if(y>m)y-=m; if(t==1){ double L1=y-r1,R1=y+r1; sum+=max(0.0,d1*(min(R1,R3)-max(L1,L3))); }else if(t==2){ double L2=y-r2,R2=y+r2; sum+=max(0.0,d2*(min(R2,R3)-max(L2,L3))); } } } return res+sum; } inline void solve() { double t=T; double ans=0; while(t>endt) { int xx=rand()%n+1,yy=rand()%n+1; while(a[xx]==a[yy])xx=rand()%n+1,yy=rand()%n+1; swap(a[xx],a[yy]); double zp=getsum(); if(zp>ans){ ans=zp; star::ans=max(star::ans,ans); }else if(rand()<exp((ans-zp)/t/kb) * RAND_MAX)swap(a[xx],a[yy]); else ans=zp; t*=eps; } } inline void work(){ n1=read(),n2=read(),n3=read(); r1=read(); r1=sqrt(r1*r1-1); r2=read(); r2=sqrt(r2*r2-1); r3=read(); r3=sqrt(r3*r3-1); d1=read(),d2=read(); res=2*n1*r1*d1+2*n2*r2*d2; if(n3==0)return (void)printf("%.10lf",res); n=n1+n2+n3; for(int i=1;i<=n;i++) if(n1) a[i]=1,n1--; else if(n2) a[i]=2,n2--; else if(n3) a[i]=3,n3--; m=n/2+1; n=m*2; random_shuffle(a+1,a+1+n); srand(time(0));
for(int i=1;i<=100;i++) solve(); printf("%.10lf\n",ans); } } signed main(){ star::work(); return 0; }
|