CF441E.Valera and Number

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Valera is a coder. Recently he wrote a funny program. The pseudo code for this program is given below:

//input: integers x, k, p
a = x;
for(step = 1; step <= k; step = step + 1){
rnd = [random integer from 1 to 100];
if(rnd <= p)
a = a * 2;
else
a = a + 1;
}

s = 0;

while(remainder after dividing a by 2 equals 0){
a = a / 2;
s = s + 1;
}

Now Valera wonders: given the values x, k and p, what is the expected value of the resulting number s?

瓦列拉是一名程序员。最近他编写了一个有趣的程序。该程序的伪代码如下所示:

// 输入:整数 x、k、p
a = x;
for(step = 1; step <= k; step = step + 1){
rnd = [从 1 到 100 中均匀随机选取的整数];
if(rnd <= p)
a = a * 2;
else
a = a + 1;
}

s = 0;

while(a 除以 2 的余数等于 0){
a = a / 2;
s = s + 1;
}

现在瓦列拉想知道:给定参数 x、k 和 p,最终得到的数 s 的期望值是多少?

输入格式

The first line of the input contains three integers x, k, p (1 ≤ x ≤ 109; 1 ≤ k ≤ 200; 0 ≤ p ≤ 100).

输入的第一行包含三个整数 xx、kk、pp(1≤x≤1091 \le x \le 10^9;1≤k≤2001 \le k \le 200;0≤p≤1000 \le p \le 100)。

输出格式

Print the required expected value. Your answer will be considered correct if the absolute or relative error doesn't exceed 10 - 6.

输出所需的期望值。只要您的答案的绝对误差或相对误差不超过 10−610^{-6},即视为正确。

输入输出样例

  • 输入#1

    1 1 50

    输出#1

    1.0000000000000
  • 输入#2

    5 3 0

    输出#2

    3.0000000000000
  • 输入#3

    5 3 25

    输出#3

    1.9218750000000

说明/提示

If the concept of expected value is new to you, you can read about it by the link:

http://en.wikipedia.org/wiki/Expected_value

如果期望值的概念对你来说是新的,你可以通过以下链接了解它:

http://en.wikipedia.org/wiki/Expected_value

输入解题思路,AI测评打分。不知道怎么写?

首页