結果
問題 | No.813 ユキちゃんの冒険 |
ユーザー |
|
提出日時 | 2020-08-05 14:47:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 726 bytes |
コンパイル時間 | 1,080 ms |
コンパイル使用メモリ | 73,156 KB |
最終ジャッジ日時 | 2025-01-12 14:54:38 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
#include <iostream> #include <iomanip> using ldouble = long double; using pdouble = std::pair<ldouble, ldouble>; pdouble merge(pdouble a, pdouble b) { if (a.first == 1) return pdouble(1, 0); return pdouble(a.first + a.second * a.second * b.first / (1 - a.first * b.first), a.second * b.second / (1 - a.first * b.first)); } void solve() { int n; ldouble p, q; std::cin >> n >> p >> q; pdouble base(p, q); auto ans = base; --n; while (n--) ans = merge(ans, base); std::cout << std::fixed << std::setprecision(20) << ans.first << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }