結果

問題 No.555 世界史のレポート
ユーザー 37zigen37zigen
提出日時 2017-08-12 02:10:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 786 bytes
コンパイル時間 1,889 ms
コンパイル使用メモリ 77,608 KB
実行使用メモリ 54,384 KB
最終ジャッジ日時 2024-04-21 00:35:03
合計ジャッジ時間 5,081 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
52,772 KB
testcase_01 AC 121 ms
54,384 KB
testcase_02 AC 115 ms
54,116 KB
testcase_03 AC 122 ms
54,044 KB
testcase_04 AC 118 ms
54,092 KB
testcase_05 AC 107 ms
54,164 KB
testcase_06 AC 118 ms
54,132 KB
testcase_07 AC 111 ms
53,016 KB
testcase_08 AC 121 ms
53,944 KB
testcase_09 AC 115 ms
53,620 KB
testcase_10 AC 137 ms
53,996 KB
testcase_11 AC 136 ms
54,176 KB
testcase_12 AC 138 ms
54,376 KB
testcase_13 AC 129 ms
53,576 KB
testcase_14 AC 122 ms
53,200 KB
testcase_15 AC 130 ms
54,112 KB
testcase_16 AC 134 ms
53,852 KB
testcase_17 AC 121 ms
53,156 KB
testcase_18 AC 134 ms
54,352 KB
testcase_19 AC 140 ms
54,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	final long MODULO = 1_000_000_000 + 7;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = sc.nextInt();
		int v = sc.nextInt();
		int[] dp = new int[2 * n - 2 + 1];
		Arrays.fill(dp, Integer.MAX_VALUE / 16);
		dp[1] = 0;
		for (int i = 1; i < dp.length; ++i) {
			for (int j = i * 2; j < dp.length; j += i) {
				dp[j] = Math.min(dp[j], dp[i] + (j / i - 1) * v + c);
			}
		}
		long ans = Long.MAX_VALUE / 16;
		for (int i = n; i < dp.length; ++i) {
			ans = Math.min(ans, dp[i]);
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}
0