結果
| 問題 |
No.813 ユキちゃんの冒険
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-15 23:20:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,248 bytes |
| コンパイル時間 | 1,262 ms |
| コンパイル使用メモリ | 118,472 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-02 06:40:44 |
| 合計ジャッジ時間 | 3,839 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 WA * 1 |
ソースコード
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;
const int RIGHT = 0;
const int LEFT = 1;
int main()
{
int n;
double p, q;
cin >> n >> p >> q;
vector<vector<double> > dp(2, vector<double>(n+2, 0.0));
dp[RIGHT][1] = 1.0;
double ans = 0.0;
for(int i=0; i<10000; ++i){
vector<vector<double> > nextDp(2, vector<double>(n+2, 0.0));
for(int j=1; j<=n; ++j){
nextDp[LEFT][j-1] += dp[RIGHT][j] * p;
nextDp[RIGHT][j+1] += dp[LEFT][j] * p;
nextDp[RIGHT][j+1] += dp[RIGHT][j] * q;
nextDp[LEFT][j-1] += dp[LEFT][j] * q;
}
dp = move(nextDp);
ans += dp[LEFT][0];
}
cout.setf(ios_base::fixed, ios_base::floatfield);
cout << setprecision(10) << ans << endl;
return 0;
}