1011: [HNOI2008] a distant planet

Source: Internet
Author: User

1011: [HNOI2008] Distant planet time limit:10 Sec Memory limit:162 mbsec Special Judge
submit:2241 solved:793
[Submit] [Status] Description

On a straight line of n planets, there are planets I in the X=i, and Planet J is subjected to the force of the planet I, when and only as I<=aj. At this time J is subjected to a force of fi->j=mi*mj/(J-i) where a is a very small constant, so it is intuitively said that each planet is only affected by distant planets. Please calculate the force of each planet, as long as the relative error of the result is not more than 5%.

Input

The first line is two integers n and a. 1<=n<=10^5.0.01< a < =0.35
Next n lines enter the mass Mi of n planets, guaranteeing 0<=mi<=10^7

Output

n rows, sequentially outputting the forces of each planet

Sample Input5 0.3
3
5
6
2
4Sample Output0.000000
0.000000
0.000000
1.968750
2.976000HINT

The exact result should be 0 0 0 2 3, but the result error of the sample output is not more than 5%, also

Source

The puzzle: Oh oh ah ... I feel like I really want to catch the chicken--only to know that there will be approximate treatment in the Physics competition Chemistry contest. The general idea is to first segment processing, and then the small part of the violence, the large part of the approximate treatment, the effective use of the error in the title of not more than 5% oh ^_^ next start to quote (feel that the provincial election can be a drop off this problem is God OTL, this approximate really slightly strange ah)

Set F[i] The gravitational pull of the planet I, G[i] represents the last source of gravity of the first planet

Then small range (I was taking α* I < 9) violence, a wide range on the mess, ignoring the divisor (i-j) gap

1/**************************************************************2Problem:10113 User:hansbug4 language:pascal5 result:accepted6Time:2296Ms7Memory:1984KB8****************************************************************/9  Ten Constst= -; One var A I,j,k,l,m,n:longint;  - p:extended; -B,c:Array[0..100010] ofLongint; theA:Array[0..100010] ofextended; - begin - readln (n,p); -      fori:=1  toN Doread (b[i]); + Readln; -      fori:=1  toN DoC[i]:=trunc (i*p); +      fori:=1  toN Do A         begin at             ifA[i]<>0  Thena[i]:=0; -             ifC[i]<>0  Then -                 begin -                     ifI<=st Then -                         begin -                              forj:=1  toC[i] Doa[i]:=a[i]+b[j]/(I-j); ina[i]:=a[i]*B[i]; -                         End to                     Else +                         begin -A[i]:= (A[i-st]/b[i-st]) * ((i-st-(c[i-st]/2))/(I-(c[i-st]/2))); the                              forj:=c[i-st]+1  toC[i] Doa[i]:=a[i]+b[j]/(I-j); *a[i]:=a[i]*B[i]; $                         End;Panax Notoginseng                 End; -         End; the      fori:=1  toN DoWriteln (A[i]:0:6); + Readln; A End.

1011: [HNOI2008] a distant planet

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.