結果
| 問題 | No.555 世界史のレポート |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-08-11 23:33:32 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 681 bytes |
| コンパイル時間 | 644 ms |
| コンパイル使用メモリ | 121,156 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 21:29:41 |
| 合計ジャッジ時間 | 1,460 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
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;
}