結果
問題 | No.813 ユキちゃんの冒険 |
ユーザー |
![]() |
提出日時 | 2019-04-12 22:57:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 598 bytes |
コンパイル時間 | 1,502 ms |
コンパイル使用メモリ | 166,784 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-21 08:27:52 |
合計ジャッジ時間 | 2,349 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; const long double EPS = (1e-16); #define INF (1e9) #define PI (acos(-1)) //const ll mod = 1000000007; long double dp[1005]; int main() { cout.precision(10); cin.tie(0); ios::sync_with_stdio(false); long double p, q; int N; cin >> N >> p >> q; if(p + EPS >= 1.0) { cout << 1 << endl; return 0; } dp[1] = p; for(int i = 2; i <= N; i++) { dp[i] = p + q * dp[i - 1] * q / (1 - dp[i - 1] * p); } cout << dp[N] << endl; return 0; }