F.Kevin and Expected Value | |||||
|
|||||
Description | |||||
Kevinsogo is a professor of mathematics, One day he gave an assignment to his students which was hard for them. The students want you to help them in solving the problem. Given the value of N, X = rand( ) mod N
Note that rand() returns an integer between 0 and 10^100 (inclusive) uniformly at random. Find out the expected value of Y. |
|||||
Input | |||||
The first line contains an integer T i.e. the number of test cases. The next T lines will each contain an integer N. 1≤T≤10000 1≤N≤5×10^6 |
|||||
Output | |||||
Print the output corresponding to each test case in a separate line. Remain exactly 3 number after decimal point. |
|||||
Sample Input | |||||
3 1 5 10 |
|||||
Sample Output | |||||
0.000 1.696 2.438 |
这题目Y是个极限。。。。刚拿到手不知道怎么求。。但因为x是随机的,x范围是0—-n-1并且出现的概率都是1/n,所以用数学期望求。。。。第一次做这种题目。。。。QAQ。。。。。
很陌生的一道题目。。。。记下来
#include
#include
#include
using namespace std;
int main()
{
int n,t
cin>>t;
while(t--)
{
double sum = 0;
for(int i =0; i