bzoj 1011 近似估计

开始看这道题的时候没什么思路,后来忍不住看了题解,发现自己真是水啊。。。

自从学OI来第一次看到用约等的题

首先我们设w[i]为第i个星球的答案,g[i]为第i个星球受到1-g[i]个星球的引力

那么我们想办法递推,用w[i]推出w[ii],

我们设ii=i+t

那么。。。。那么我还是用手写然后照张照片吧

/**************************************************************
    Problem: 1011
    User: BLADEVIL
    Language: Pascal
    Result: Accepted
    Time:2428 ms
    Memory:1984 kb
****************************************************************/
 
//By BLADEVIL
const
    t                               =100;
 
var
    n                               :longint;
    a                               :extended;
    m, g                            :array[0..100010] of longint;
    w                               :array[0..100010] of extended;
    i, j                            :longint;
     
begin
    read(n,a);
    for i:=1 to n do read(m[i]);
    for i:=1 to n do g[i]:=trunc(i*a);
    for i:=1 to n do
    begin
        w[i]:=0;
        if g[i]=0 then continue;
        if i<=t then
        begin
            for j:=1 to g[i] do
                w[i]:=w[i]+m[j]/(i-j);
            w[i]:=w[i]*m[i];
        end else
        begin
            w[i]:=(w[i-t]/m[i-t])*((i-t-(g[i-t]/2))/(i-(g[i-t]/2)));
            for j:=g[i-t]+1 to g[i] do
                w[i]:=w[i]+m[j]/(i-j);
            w[i]:=w[i]*m[i];
        end;
    end;
    for i:=1 to n do writeln(w[i]:0:6);
end.

 

 

posted on 2013-11-20 16:00  BLADEVIL  阅读(458)  评论(0编辑  收藏  举报