提出 #52616739


ソースコード 拡げる

#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define ull unsigned long long
#define pa first
#define pb second
#define endl '\n'
#define vint vector<int>
#define vlong vector<ll>
#define pii pair<int, int>
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define rng(i, a, b) for (int i = int(a); i <= int(b); i++)
#define per(i, a, b) for (int i = int(b - 1); i >= int(a); i--)
#define gnr(i, a, b) for (int i = int(b); i >= int(a); i--)
using namespace std;
#define ATC
#ifdef ATC
#include <atcoder/all>
using namespace atcoder;
#endif

#ifdef MT
void solve()
{
}
#endif
ll N, a, x, y;

map<ll, double> dp;

double dfs(ll n)
{
    if (n == 0)
        return 0;
    if (dp.count(n))
        return dp[n];
    else
        return dp[n] = min(dfs(n / a) + x, 1.0 / 5.0 * (dfs(n / 2) + dfs(n / 3) + dfs(n / 4) + dfs(n / 5) + dfs(n / 6)) + 6.0 / 5.0 * y);
}

int main(void)
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> N >> a >> x >> y;
    cout << fixed << setprecision(10) << dfs(N) << endl;

#ifdef MT
    int t;
    cin >> t;
    for (int i = 0; i < t; i++)
        solve();
#endif
}

提出情報

提出日時
問題 E - Toward 0
ユーザ L1bra
言語 C++ 20 (gcc 12.2)
得点 450
コード長 1207 Byte
結果 AC
実行時間 7 ms
メモリ 4416 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 450 / 450
結果
AC × 3
AC × 30
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All max.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
max.txt AC 7 ms 4256 KiB
random_01.txt AC 7 ms 4312 KiB
random_02.txt AC 7 ms 4344 KiB
random_03.txt AC 7 ms 4308 KiB
random_04.txt AC 7 ms 4336 KiB
random_05.txt AC 7 ms 4324 KiB
random_06.txt AC 6 ms 4216 KiB
random_07.txt AC 7 ms 4268 KiB
random_08.txt AC 7 ms 4332 KiB
random_09.txt AC 7 ms 4272 KiB
random_10.txt AC 7 ms 4244 KiB
random_11.txt AC 7 ms 4264 KiB
random_12.txt AC 7 ms 4324 KiB
random_13.txt AC 7 ms 4312 KiB
random_14.txt AC 7 ms 4340 KiB
random_15.txt AC 7 ms 4272 KiB
random_16.txt AC 6 ms 4260 KiB
random_17.txt AC 7 ms 4416 KiB
random_18.txt AC 6 ms 4296 KiB
random_19.txt AC 7 ms 4308 KiB
random_20.txt AC 6 ms 4220 KiB
random_21.txt AC 1 ms 3704 KiB
random_22.txt AC 1 ms 3888 KiB
random_23.txt AC 7 ms 4260 KiB
random_24.txt AC 7 ms 4320 KiB
random_25.txt AC 7 ms 4312 KiB
random_26.txt AC 7 ms 4320 KiB
sample_01.txt AC 1 ms 3844 KiB
sample_02.txt AC 1 ms 3860 KiB
sample_03.txt AC 6 ms 4376 KiB