結果

問題 No.555 世界史のレポート
ユーザー nebukuro09nebukuro09
提出日時 2017-08-11 23:33:32
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 811 ms
コンパイル使用メモリ 105,864 KB
実行使用メモリ 5,160 KB
最終ジャッジ日時 2023-09-03 15:48:57
合計ジャッジ時間 2,088 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 6 ms
4,380 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 5 ms
4,384 KB
testcase_13 AC 5 ms
5,160 KB
testcase_14 AC 6 ms
4,828 KB
testcase_15 AC 6 ms
4,380 KB
testcase_16 AC 5 ms
4,384 KB
testcase_17 AC 6 ms
4,380 KB
testcase_18 AC 6 ms
4,384 KB
testcase_19 AC 7 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

const long INF = 1L << 59;
const long MOD = 10 ^^ 9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto s = readln.split.map!(to!long);
    auto C = s[0];
    auto V = s[1];
    auto dp = new long[](2 * N + 1);
    fill(dp, INF);
    dp[1] = 0;

    foreach (i; 1..N) {
        long cost = (dp[i] + C) % MOD;
        for (int j = i + i; j <= 2 * N; j += i) {
            cost = (cost + V) % MOD;
            dp[j] = min(dp[j], cost);
        }
    }

    dp[N..2*N+1].reduce!min.writeln;
}
0