Ilya got tired of sports programming, left university and got a job in the subway. He was given the task to determine the escalator load factor. 

Let's assume that n people stand in the queue for the escalator. At each second one of the two following possibilities takes place: either the first person in the queue enters the escalator with probability p, or the first person in the queue doesn't move with probability (1 - p), paralyzed by his fear of escalators and making the whole queue wait behind him.

Formally speaking, the i-th person in the queue cannot enter the escalator until people with indices from 1 to i - 1 inclusive enter it. In one second only one person can enter the escalator. The escalator is infinite, so if a person enters it, he never leaves it, that is he will be standing on the escalator at any following second. Ilya needs to count the expected value of the number of people standing on the escalator after t seconds. 

Your task is to help him solve this complicated task.


-----Input-----

The first line of the input contains three numbers n, p, t (1 ≤ n, t ≤ 2000, 0 ≤ p ≤ 1). Numbers n and t are integers, number p is real, given with exactly two digits after the decimal point.


-----Output-----

Print a single real number — the expected number of people who will be standing on the escalator after t seconds. The absolute or relative error mustn't exceed 10^{ - 6}.


-----Examples-----
Input
1 0.50 1

Output
0.5

Input
1 0.50 4

Output
0.9375

Input
4 0.20 2

Output
0.4

Difficulty: interview

Starter code:

Solutions:
a = input().split()
n = int(a[0])
p = float(a[1])
t = int(a[2])
den = 100 ** t
p = round(p * 100 + 1e-9)
q = 100 - p
ncr = [1 for i in range(2001)]
for i in range(1, t + 1):
        ncr[i] = ncr[i - 1] * (t - i + 1) // i
ans = 0
for i in range(2001):
        ans += min(i, n) * ncr[i] * (p ** i) * (q ** (t - i)) if t >= i else 0
ans /= den
print(ans)


def main():
    tmp = input().split()
    n, p, t = int(tmp[0]), float(tmp[1]), int(tmp[2])
    q = 1. - p
    res = [0.] * (n + 1)
    res[0] = 1.
    for _ in range(t):
        tmp = [x * q for x in res]
        tmp[-1] = res[-1]
        for i in range(n):
            tmp[i + 1] += res[i] * p
        res = tmp
    print(sum(x * i for i, x in enumerate(res)))


def __starting_point():
    main()
__starting_point()

__author__ = 'PrimuS'

import decimal
decimal.getcontext().prec = 1000

inp = input().split()
# inp = [417,0.57,742]
n = int(inp[0])
p = decimal.Decimal(inp[1])
t = int(inp[2])

facs = {}
ps = {}
p1s = {}
facs[0] = decimal.Decimal(1)
ps[0] = decimal.Decimal(1)
p1s[0] = decimal.Decimal(1)
for i in range(1, max(n,t) + 1):
    facs[i] = facs[i-1] * decimal.Decimal(i)
    ps[i] = ps[i-1] * p
    p1s[i] = p1s[i-1] * (1-p)

def c(n, k):
    return facs[n] / facs[n-k] / facs[k]

# print(c(2000, 1000))

res = decimal.Decimal(0)
up = min(n, t)
if n < t:
    up = n - 1

for i in range(1, up + 1):
    cur = decimal.Decimal(i)
    cur *= c(t, i)
    cur *= ps[i]
    cur *= p1s[t - i]
    res += cur
    # print(res)

if n < t:
    cur2 = t
    while cur2 >= n:
        cur = decimal.Decimal(n)
        cur *= c(cur2 - 1, n - 1)
        cur *= ps[n]
        cur *= p1s[cur2 - n]
        res += cur
        cur2 -= 1
        # print(cur, res)

# decimal.getcontext().prec = 15
# res = decimal.Decimal(res)
print(res)

a, b, c = list(map(float, input().split(' ')))
a = int(a)
c = int(c)
#dp[i][j] = probability that after i seconds, ther are j ppl on escalator
dp = [[0] * (c+1) for _ in range(c+1)]

for i in range(c+1):
    for j in range(c+1):
        if i == 0:
            if j == 0:
                dp[i][j] = 1
            else:
                dp[i][j] = 0
        else:
            if j > a:
                dp[i][j] = 0
            elif j == a:
                dp[i][j] = dp[i-1][j-1]*b + dp[i-1][j]                
            else:
                dp[i][j] = (1-b) * dp[i-1][j] + b * dp[i-1][j-1]
sumx = 0
for i in range(c+1):
    sumx += i * dp[c][i]
print(sumx)


inp = input().split()
n, p, t = int(inp[0]), float(inp[1]), int(inp[2])
dp = [[0] * (n + 2) for i in range(t + 2)]
dp[0][0] = 1.0
for i in range(t + 1):
    for j in range(n + 1):
        if j == n:
            dp[i + 1][j] += dp[i][j]
        else:
            dp[i + 1][j + 1] += dp[i][j] * p
            dp[i + 1][j] += dp[i][j] * (1 - p)
print(sum(dp[t][i] * i for i in range(n + 1))) 
 


def find_expected_people(people_count, probability, seconds):
    # the probability after i seconds to have k people on the escalator
    current_row = [0.] * (people_count + 1)
    current_row[0] = 1.

    for sec in range(1, seconds + 1):
        next_row = [x * (1. - probability) for x in current_row]
        next_row[-1] = current_row[-1]

        for person in range(people_count):
            next_row[person + 1] += current_row[person] * probability
        current_row = next_row

    return sum(index * value for index, value in enumerate(current_row))


def main():
    raw_input = input().split()
    people_count = int(raw_input[0])
    probability = float(raw_input[1])
    seconds = int(raw_input[2])

    print(find_expected_people(people_count, probability, seconds))

def __starting_point():
    main()

__starting_point()

def find_expected_people(people_count, probability, seconds):
    # probabilities after i seconds to have k people on the escalator
    current_row = [0.] * (people_count + 1)
    current_row[0] = 1.

    for sec in range(1, seconds + 1):
        # default probabilities for next_row when all stay
        next_row = [x * (1. - probability) for x in current_row]
        next_row[-1] = current_row[-1]

        for person in range(people_count):
            # when person go to escalator
            next_row[person + 1] += current_row[person] * probability

        current_row = next_row

    return sum(index * value for index, value in enumerate(current_row))


def main():
    raw_input = input().split()
    people_count = int(raw_input[0])
    probability = float(raw_input[1])
    seconds = int(raw_input[2])

    print(find_expected_people(people_count, probability, seconds))

def __starting_point():
    main()

__starting_point()

xs = input().split()
n, p, t = int(xs[0]), float(xs[1]), int(xs[2])
cur, nxt = [0.0] * (n + 1), [0.0] * (n + 1)
cur[0] = 1.0
for i in range(t):
    nxt[n] = cur[n]
    for j in range(n):
        nxt[j] = cur[j] * (1.0 - p)
    for j in range(n):
        nxt[j + 1] += cur[j] * p
    cur, nxt = nxt, cur
print(sum(cur[i] * i for i in range(n + 1)))

def main():
    a = input().split()
    n = int(a[0])
    p = float(a[1])
    t = int(a[2])
    z = [0.0] * (t+2)
    for i in range(t+2):
        z[i] = [0] * (n+2)
    l = 0.
    z[0][0] = 1.
    for i in range(t+1):
        for j in range(n+1):
            if j == n:
                z[i+1][j] += z[i][j]
            else:
                z[i+1][j+1] += z[i][j] * p
                z[i+1][j] += z[i][j] * (1-p)
    for j in range(n+1):
        l += z[t][j] * j
    print(l)
def __starting_point():
    main()

__starting_point()

import sys


try:
    while True:
        dp = [[0 for j in range(2001)] for i in range(2001)] * 2001
        n, p, t = map(float, input().split(" "))
        n = int(n)
        t = int(t)
        dp[0][0] = 1
        for i in range(1, t+1, 1):
            for j in range(0, n+1, 1):
                if j == n:
                    dp[i][j] = dp[i-1][j]
                else:
                    dp[i][j] = dp[i-1][j] * (1-p)
                if j > 0:
                    dp[i][j] += dp[i-1][j-1] * p
        ans = 0
        for i in range(n+1):
            ans += i * dp[t][i]
        print(ans)
except EOFError:
    pass

inputs = [x for x in input().split()]
n,p,t = int(inputs[0]), float(inputs[1]), int(inputs[2])

saved = [[0 for _ in range(n)] for _ in range(t)]
saved[0][0] = p

for i in range(1, t):
    saved[i][0] = saved[i-1][0] + ((1 - saved[i-1][0]) * p)

for i in range(1, t):
    for j in range(1, n):
            saved[i][j] = saved[i - 1][j - 1] * p + (saved[i - 1][j]) * (1 -p)

#print(saved)
print(sum(saved[-1]))

n, p, t = input().split()
n, p = int(n), float(p)
f = [p] * n + [0]
for i in range(int(t) - 1): f = [f[k] * (1 - p) + p * (1 + f[k - 1]) for k in range(n)] + [0]
print(f[-2])

n, p, t = input().split()
n, p = int(n), float(p)
f = [p] * n + [0]
for i in range(int(t) - 1): f = [f[k] * (1 - p) + p * (1 + f[k - 1]) for k in range(n)] + [0]
print(f[-2])


n, p, t = input().split()
n, p = int(n), float(p)
f = [p] * n + [0]
for i in range(int(t) - 1): f = [f[k] * (1 - p) + p * (1 + f[k - 1]) for k in range(n)] + [0]
print(f[-2])


n, p, t = input().split()
n, p = int(n), float(p)
f = [p] * n + [0]
for i in range(int(t) - 1): f = [f[k] * (1 - p) + p * (1 + f[k - 1]) for k in range(n)] + [0]
print(f[-2])


n, p, t = input().split()
n, p = int(n), float(p)
f = [p] * n + [0]
for i in range(int(t) - 1): f = [f[k] * (1 - p) + p * (1 + f[k - 1]) for k in range(n)] + [0]
print(f[-2])


n, p, t = input().split()
n, p = int(n), float(p)
f = [p] * n + [0]
for i in range(int(t) - 1): f = [f[k] * (1 - p) + p * (1 + f[k - 1]) for k in range(n)] + [0]
print(f[-2])


n, p, t = input().split()
n, p = int(n), float(p)
f = [p] * n + [0]
for i in range(int(t) - 1): f = [f[k] * (1 - p) + p * (1 + f[k - 1]) for k in range(n)] + [0]
print(f[-2])


n, p, t = input().split()
n, p = int(n), float(p)
f = [p] * n + [0]
for i in range(int(t) - 1): f = [f[k] * (1 - p) + p * (1 + f[k - 1]) for k in range(n)] + [0]
print(f[-2])


n, p, t = input().split()
n, p = int(n), float(p)
f = [p] * n + [0]
for i in range(int(t) - 1): f = [f[k] * (1 - p) + p * (1 + f[k - 1]) for k in range(n)] + [0]
print(f[-2])


n, p, t = list(map(float, input().split()))
n, t = int(n + 0.5), int(t + 0.5)
if p < 0.001 or p > 0.999: 
  print(n * p)
  return
from math import exp, lgamma, log
print('%.10f' %sum( exp(i * log(p) + (t - i) * log(1 - p) + lgamma(t + 1) - lgamma(i + 1) - lgamma(t - i + 1)) * min(i, n) for i in range(t + 1))) 


n, p, t = input().split()
n, p = int(n), float(p)
f = [p] * n + [0]
for i in range(int(t) - 1): f = [f[k] * (1 - p) + p * (1 + f[k - 1]) for k in range(n)] + [0]
print(f[-2])

n, p, t = input().split()
n = int(n)
t = int(t)
p = float(p)
ans = 0.0
s = t
if abs(1.0 - p) > 1e-6:
    a1 = 1.0
    for i in range(1, t + 1):
        a1 = a1 * (t - i + 1) / i if i <= t else 0
        a1 = a1 * p
        while (a1 > 1e5) and (s > i):
            a1 *= (1 - p)
            s -= 1
        while (s < i):
            a1 /= (1 - p)
            s += 1
        a2 = (1 - p) ** (s - i)
        #print(a1, a2, s, i)
        ans += a1 * a2 * min(i, n)
else:
    ans = min(n, t)
print(ans)

dp=[[0 for i in range(2005)]for i in range(2005)]
n,p,t=0,0,0
n,p,t=map(float,input().split())
n,t=int(n),int(t)
dp[0][0]=1
for i in range(1,t+1):
	for j in range(n+1):
		if j==n :
			dp[i][j]=dp[i-1][j]
		else :
			dp[i][j]=dp[i-1][j]*(1-p)
		if j :
			dp[i][j]+=dp[i-1][j-1]*p
ans=0
for i in range(n+1):
	# print(i,dp[t][i])
	ans+=i*dp[t][i]
print(ans)

import sys

n, p, t = list(map(str, sys.stdin.readline().split()))
n = int(n)
p = float(p)
t = int(t)

def CC(nn,k):
    tmp = n
    t = max(nn - k, k)
    for i in range(1, min(nn - k, k) + 1):
        tmp = tmp * (t + i) * (1 - p) / i
    if k > nn - k:
        tmp = tmp * pow(1-p,k + k - nn)
    return tmp

def C(n, k):
    tmp = 1
    if n - k > k:
        tmp = tmp * pow(1 - p, n - k - k)
    else:
        tmp = tmp * pow(p, k + k - n)
    t = max(n - k, k)
    for i in range(1, min(n - k, k) + 1):
        tmp = tmp * (t + i) * p * (1 - p) / i

    return tmp


if n >= t:
    print(t * p)
elif p != 1 and p != 0:
    a = 0
    b = 0
    for i in range(n):
        q = C(t, i)
        a = a + q * i
        b = b + q
    a = a + (1 - b) * n
    print(a)
    b = n
    for i in range(t - n):
        b = b + CC(i + 1,n + i)
    b = b * pow(p,n)
    #print(a + b)
else:
    if p == 1:
        print(n)
    else:
        print(0)