Card (Bestcoder #26 B)

Source: Internet
Author: User

Card


Time limit:10000/5000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 218 Accepted Submission (s): 86
Special Judge


Problem Descriptionthere is x cards on the desk, they is numbered from 1 to X. The score of the card which is numbered I (1<=i<=x) is I. Every round Biebie picks one card out of the X Cards,then puts it back. He does the same operation for B rounds. Assume the score of the j-th card he picks iss j &NBSP; . You is expected to calculate the expectation of the sum of the different score he picks.Inputmulti Test Cases,the First line of this input is a number T which indicates the number of test cases.
In the next T-lines, every line contain x,b separated by exactly one space.

[Technique specification]
All numbers is integers.
1<=t<=500000
1<=x<=100000
1<=b<=5 Outputeach case occupies one line. The output format is case #id: ans, here ID is the data number which starts from 1,ans are the expectation, accurate to 3 D Ecimal places.
See the sample for more details. Sample Input2 2 3 3 3 sample Outputcase #1:2.625 case #2:4.222 HintFor the first case, all possible combinations Biebie can pick is (1, 1, 1), (1,1,2), (1,2,1), (1,2,2), (2,1,1), (2,1,2), 2,2,1 ), (2,2,2) for (1,1,1), there are only one kind number i.e. 1, and the sum of different score is 1. However, for (1,2,1), there was, kind numbers i.e. 1 and 2, so the sum of different score is 1+2=3. So the sums of different score to corresponding combination be 1,3,3,3,3,3,3,2 so the expectation is (1+3+3+3+3+3+3+2)/8= 2.625

1002 Card
Set Xi to indicate whether the card with the score I is selected in the B operation, Xi=1 is selected, Xi=0 is not selected to
So expect EX=1*X1+2*X2+3*X3+...+X*XX
The probability of Xi being selected in the B-time is (1-1/x) ^b
Then e (Xi) = N (1-1/x) ^b
Then Ex=1*e (X1) +2*e (X2) +3*e (X3) +...+x*e (Xx) = (1+x) *x/2* (n (1-1/x) ^b)

Card (Bestcoder #26 B)

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.