結果
| 問題 |
No.813 ユキちゃんの冒険
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2021-06-15 01:35:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,461 ms / 2,000 ms |
| コード長 | 1,442 bytes |
| コンパイル時間 | 1,029 ms |
| コンパイル使用メモリ | 115,312 KB |
| 最終ジャッジ日時 | 2025-01-22 08:21:21 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int n;
double p, q;
cin >> n >> p >> q;
vector<double> p0(n+1), p1(n+1);
vector<double> p0_pre(n+1), p1_pre(n+1);
p0[1] = 1;
auto ok = [&](){
auto p = accumulate(p0.begin(), p0.end(), 0.0)+accumulate(p1.begin(), p1.end(), 0.0);
// cout << p << endl;
return p < 0.0009;
};
double ans = 0.0;
while(!ok()){
swap(p0, p0_pre);
swap(p1, p1_pre);
p0[0] = 0; p0[n] = 0;
p1[0] = 0; p1[n] = 0;
ans += p0_pre[1]*p+p1_pre[1]*q;
for(int i = 1; i <= n-1; i++){
p0[i] = p0_pre[i-1]*q+p1_pre[i-1]*p;
p1[i] = p0_pre[i+1]*p+p1_pre[i+1]*q;
}
}
cout << ans << endl;
}
milanis48663220