2016武汉科技大学邀请赛现场赛 E题

来源:互联网 发布:淘宝手机详情页装修 编辑:程序博客网 时间:2024/05/11 04:45

WAM

Time Limit: 1 Sec  Memory Limit: 128 MB   64bit IO Format: %lld
Submitted: 24  Accepted: 12  Special Judge
[Submit][Status][Web Board]

Description

WAM is a fantastic game. It’s full name is WHAC-A-MOLE, but it is different from the usual one we played.
Open this APP, ZiP finds that only one mole hole on the screen, so at most one mole will appear at the same time. After clicking the start button, a mole will appear once after a while, but stays for a short time. So if ZiP does not concentrate himself in the game, he could not hit the mole.
Once ZiP hits the mole, he could get some score. He could get n points if it is the n-th time he hit the mole consecutively, etc. He could get 1+2+3=6 points after hitting a mole consecutively for 3 times. But he got 0 if he misses it.
We have , which is the possibility that ZiP could hit the mole.
Please calculate the exception score he could get after hitting M times.
 

Input

The first line of input contains the number of test case T(T<=1000) . The descriptions of the test cases follow:
Each of the test cases has a single line contains a integer M(0<=M<=1e5)and a real number p(0<=p<=1)  .
 

Output

For each test case, output a line with a real number - the answer.
The checker program will consider your answer correct, if the absolute error or relative error is less than 1e-5.

Sample Input

31 010 11 0.5

Sample Output

0.00000055.0000000.500000


题意:给出n个点,以及每个点的概率,计算连续n个点的数学期望

题解:E(n)=1*p^n+2*p^(n-1)+...+n*p这个不用解释了吧

0 0
原创粉丝点击