almost 4 years ago

orz公式君!!

因为精度范围是5%所以算一个大致的约数即可

但是这么写总是挂0.0

所以……另一个暴力的做法,sum(m[i]m[j]/(i-j)) ------->m[i]sum(g(i))/(i-mid)

其中mid=(1+g(i))>>1;

因为是约数嘛……(i-j)约了一下

orzydc!!!

#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define g(i) (int)floor((ld)i*a+eps)
#define range 2000
#define eps 1e-6
#define ld long double
usingnamespacestd;
intn;doublea;
longdoublef[100010];
longlongm[100010],sum[100010];
intmain()
{
    inti,j,border1,mid;
    scanf("%d%lf",&n,&a);
    for(i=1;i<=n;i++)
     scanf("%lld",&m[i]),sum[i]=sum[i-1]+m[i];
    for(i=1;i<=n;i++)
    {
        border1=g(i);
        if(border1<=4000)
        {
          for(intj=1;j<=border1;j++)
            if(i!=j)f[i]+=((ld)m[i]*m[j])/(ld)(i-j);          
        }
         else
         {
            mid=(border1+1)>>1;
           f[i]=(ld)m[i]*sum[border1]/(ld)(i-mid);
         }
    }
    for(i=1;i<=n;i++)
      printf("%.12lf\n",(double)f[i]);
}
← 【bzoj3203】【凸包】【三分】【dp】保护出题人 【bzoj3203】【凸包】【三分】【dp】保护出题人 →
 
comments powered by Disqus