結果

問題 No.813 ユキちゃんの冒険
ユーザー mamekinmamekin
提出日時 2019-04-15 23:30:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,367 bytes
コンパイル時間 1,207 ms
コンパイル使用メモリ 117,552 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-05 09:43:24
合計ジャッジ時間 10,729 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#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<30000; ++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];
}
double rest = 0.0;
for(int j=1; j<=n; ++j)
rest += dp[RIGHT][j] + dp[LEFT][j];
ans /= 1.0 - rest;
cout.setf(ios_base::fixed, ios_base::floatfield);
cout << setprecision(10) << ans << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0