0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 18:48:48 +00:00

518D - Ilya and Escalator

https://codeforces.com/contest/518/submission/173706602
This commit is contained in:
Baoshuo Ren 2022-09-27 21:07:31 +08:00
parent 2265bb7b7a
commit 6d2b982d60
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

37
Codeforces/518/D/D.cpp Normal file
View File

@ -0,0 +1,37 @@
#include <iostream>
#include <iomanip>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 2005;
int n, t;
double p, f[N][N], ans;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> p >> t;
f[0][0] = 1;
for (int i = 1; i <= t; i++) {
f[i][0] = (1.0 - p) * f[i - 1][0];
for (int j = 1; j < n; j++) {
f[i][j] = p * f[i - 1][j - 1] + (1.0 - p) * f[i - 1][j];
}
f[i][n] = f[i - 1][n] + p * f[i - 1][n - 1];
}
for (int i = 1; i <= n; i++) {
ans += f[t][i] * i;
}
cout << std::fixed << std::setprecision(6) << ans << endl;
return 0;
}