結果

問題 No.555 世界史のレポート
ユーザー tookunn_1213tookunn_1213
提出日時 2017-08-12 08:12:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 1,903 bytes
コンパイル時間 2,183 ms
コンパイル使用メモリ 78,332 KB
実行使用メモリ 39,884 KB
最終ジャッジ日時 2024-04-21 05:51:31
合計ジャッジ時間 4,738 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
36,684 KB
testcase_01 AC 49 ms
36,588 KB
testcase_02 AC 48 ms
36,444 KB
testcase_03 AC 53 ms
36,544 KB
testcase_04 AC 53 ms
36,376 KB
testcase_05 AC 53 ms
36,684 KB
testcase_06 AC 54 ms
36,564 KB
testcase_07 AC 56 ms
36,420 KB
testcase_08 AC 57 ms
36,588 KB
testcase_09 AC 58 ms
36,448 KB
testcase_10 AC 87 ms
39,196 KB
testcase_11 AC 92 ms
39,628 KB
testcase_12 AC 87 ms
39,188 KB
testcase_13 AC 87 ms
39,104 KB
testcase_14 AC 90 ms
39,224 KB
testcase_15 AC 92 ms
39,444 KB
testcase_16 AC 90 ms
39,200 KB
testcase_17 AC 95 ms
39,304 KB
testcase_18 AC 96 ms
39,296 KB
testcase_19 AC 101 ms
39,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	static final int INF = (int)1e9+7;
	int N,C,V;
	int[]dp;

	public void solve() {
		N = nextInt();
		C = nextInt();
		V = nextInt();

		dp = new int[N * 10 + 1];

		Arrays.fill(dp, INF);

		dp[1] = 0;
		for(int i = 1;i < N;i++){
			for(int j = 2;j * i <= N * 10;j++){
				dp[i * j] = Math.min(dp[i * j], dp[i] + C + V * (j-1));
			}
		}

		int ans = INF;
		for(int i = N;i <= N * 10;i++){
			ans = Math.min(ans, dp[i]);
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}
0