結果
問題 | No.813 ユキちゃんの冒険 |
ユーザー |
![]() |
提出日時 | 2019-04-13 00:24:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 704 bytes |
コンパイル時間 | 1,037 ms |
コンパイル使用メモリ | 102,352 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-21 08:29:05 |
合計ジャッジ時間 | 1,837 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
#include <algorithm>#include <iostream>#include <iomanip>#include <cstring>#include <string>#include <vector>#include <random>#include <bitset>#include <queue>#include <cmath>#include <stack>#include <set>#include <map>typedef long long ll;typedef long double ld;using namespace std;ld dp[1005][1005];// i->j->iとなる確率int main() {int n;ld p, q;cin >> n >> p >> q;if (q == 0) {cout << 1 << "\n";return 0;}ld P = p, Q = q;for (int i = 1; i < n; i++) {ld nextQ = Q * q / (1 - P * p);ld nextP = P + p * Q * Q / (1 - P * p);P = nextP;Q = nextQ;}cout << P << "\n";return 0;}