結果

問題 No.555 世界史のレポート
ユーザー tentententen
提出日時 2021-11-12 09:25:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 1,632 bytes
コンパイル時間 2,341 ms
コンパイル使用メモリ 77,608 KB
実行使用メモリ 38,788 KB
最終ジャッジ日時 2024-11-24 15:59:16
合計ジャッジ時間 5,555 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
37,068 KB
testcase_01 AC 49 ms
37,144 KB
testcase_02 AC 48 ms
36,640 KB
testcase_03 AC 50 ms
37,128 KB
testcase_04 AC 51 ms
36,972 KB
testcase_05 AC 49 ms
36,616 KB
testcase_06 AC 51 ms
36,908 KB
testcase_07 AC 51 ms
37,156 KB
testcase_08 AC 52 ms
36,636 KB
testcase_09 AC 51 ms
36,852 KB
testcase_10 AC 168 ms
38,668 KB
testcase_11 AC 191 ms
38,712 KB
testcase_12 AC 170 ms
38,676 KB
testcase_13 AC 148 ms
38,400 KB
testcase_14 AC 180 ms
38,656 KB
testcase_15 AC 186 ms
38,572 KB
testcase_16 AC 162 ms
38,756 KB
testcase_17 AC 180 ms
38,788 KB
testcase_18 AC 186 ms
38,524 KB
testcase_19 AC 236 ms
38,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    static int c;
    static int v;
    static int[] dp;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int c = sc.nextInt();
        int v = sc.nextInt();
        int[] dp = new int[n * 2];
        int ans = Integer.MAX_VALUE;
        for (int i = 2; i < n * 2; i++) {
            dp[i] = c + v * (i - 1);
            for (int j = 2; j <= Math.sqrt(i); j++) {
                if (i % j == 0) {
                    dp[i] = Math.min(dp[i], dp[j] + c + v * (i / j - 1));
                    dp[i] = Math.min(dp[i], dp[i / j] + c + v * (j - 1));
                }
            }
            if (i >= n) {
                ans = Math.min(ans, dp[i]);
            }
        }
        System.out.println(ans);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0