【bzoj1011】[HNOI2008]遥远的行星

#include<algorithm>
#include<iostream> 
#include<cstring>
#include<cstdlib> 
#include<cstdio>
#include<cmath> 
#include<queue>  
using namespace std;
 
typedef long double LD;

#define N 100010

long double a;

int n,T=50;

long double m[N],f[N];

int main()
{
	scanf("%d%Lf",&n,&a);
	for (int i=1;i<=n;i++)
		scanf("%Lf",&m[i]);
	for (int i=1;i<=T;i++)
	{
		int l=floor(a*i);
		for (int j=1;j<=l;j++)
			f[i]+=m[i]*m[j]/(i-j);
	}
	for (int i=1+T;i<=n;i++)
	{
		int l=floor(a*(i-T));
		int r=floor(a*i);
		for (int j=l+1;j<=r;j++)
			f[i]+=m[i]*m[j]/(i-j);
		f[i]+=m[i]*f[i-T]/m[i-T]*(i-T-1.0*l/2.0)/(i-1.0*l/2.0);
	}
	for (int i=1;i<=n;i++)
		printf("%Lf\n",f[i]);
	return 0;
}

  

 

posted @ 2016-05-21 20:52  Yangjiyuan  阅读(136)  评论(0编辑  收藏  举报