当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3105:Expectation

Special Judge 特殊评判
题目描述

Eric has constructed an easy scheme for generating random integer numbers. His scheme inputs an integer n and generates evenly distributed random integer value between 0 and (n − 1) inclusive. For example, if n = 3, the scheme generates 0, 1 or 2, each with probability 1/3.

Now Eric is planning to construct more complicated schemes. The first one will consist of two independent random generators with their outputs forwarded to his favorite XOR gate, which does bitwise exclusive or with its two inputs.

Eric’s friend Nick studies math. Nick said that the scheme is very interesting, and the most interesting thing is the expectation of the result. Now they both think how to calculate the expectation. Could you help them?

Remember that the expectation of the random variable is its average value. For a variable ξ with nonnegative integer values it can be calculated as

,

where pi is the probability of ξ being equal to i.

输入解释

The first line of the input contains the number k of cases to solve (1 ≤ k ≤ 1 000). Each case consists of a single integer 1 ≤ n ≤ 109 on a separate line.

输出解释

For each case output the expected value of the new Eric’s scheme with at least two digits after the decimal point. Output each result on a separate line.

输入样例
2
3
4
输出样例
1.33
1.50

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3105

最后修改于 2020-10-29T06:52:50+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536