結果

問題 No.2461 一点張り
ユーザー ldsybldsyb
提出日時 2023-09-08 22:53:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 789 bytes
コンパイル時間 4,140 ms
コンパイル使用メモリ 265,976 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 22:53:49
合計ジャッジ時間 4,938 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 24 ms
4,380 KB
testcase_02 AC 23 ms
4,380 KB
testcase_03 AC 43 ms
4,376 KB
testcase_04 AC 24 ms
4,376 KB
testcase_05 AC 34 ms
4,376 KB
testcase_06 AC 24 ms
4,380 KB
testcase_07 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif

int main()
{
    int64_t T;
    cin >> T;

    for (int64_t t = 0; t < T; t++)
    {
        long double p;
        int64_t k;
        cin >> p >> k;

        map<int64_t, long double> mp;

        auto f = [&](auto &&g, int64_t x) -> long double
        {
            if (mp.find(x) != mp.end())
            {
                return mp[x];
            }

            if (k <= x)
            {
                return mp[x] = 0;
            }

            long double ret = 1 + (1 - p) * g(g, x + 1);

            return mp[x] = ret;
        };

        cout << fixed << setprecision(20) << f(f, 0) << endl;
    }

    return 0;
}
0