結果

問題 No.813 ユキちゃんの冒険
ユーザー Mister
提出日時 2020-08-05 14:38:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 651 bytes
コンパイル時間 1,328 ms
コンパイル使用メモリ 73,032 KB
最終ジャッジ日時 2025-01-12 14:54:32
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>

using ldouble = long double;

using pdouble = std::pair<ldouble, ldouble>;

pdouble merge(pdouble a, pdouble b) {
    return pdouble(a.first / (1 - a.second * b.first),
                   a.second * b.second / (1 - a.second * 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;
}
0