結果
| 問題 |
No.813 ユキちゃんの冒険
|
| コンテスト | |
| ユーザー |
a
|
| 提出日時 | 2019-04-13 14:59:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 605 bytes |
| コンパイル時間 | 1,936 ms |
| コンパイル使用メモリ | 166,576 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-01-02 06:30:57 |
| 合計ジャッジ時間 | 6,572 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 WA * 21 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
void solve()
{
int n;
cin >> n;
double p, q;
cin >> p >> q;
vector<vector<double>> dp(2, vector<double>(n+2, 0));
dp[0][1] = 1;
double ans = 0;
int reptimes = 100000;
while(reptimes--)
{
vector<vector<double>> nx(2, vector<double>(n+2, 0));
for (int i = 1; i <= n; i++)
for (int j = 0; j < 2; j++)
{
nx[j^1][i-1] += dp[j][i] * p;
nx[j^1][i+1] += dp[j][i] * q;
}
ans += nx[1][0];
swap(dp, nx);
}
cout << fixed << setprecision(9) << ans << endl;
}
int main()
{
solve();
//cout << "yui(*-v・)yui" << endl;
return 0;
}
a