mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 14:18:47 +00:00
518D - Ilya and Escalator
https://codeforces.com/contest/518/submission/173706602
This commit is contained in:
parent
2265bb7b7a
commit
6d2b982d60
37
Codeforces/518/D/D.cpp
Normal file
37
Codeforces/518/D/D.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user