結果

問題 No.555 世界史のレポート
ユーザー mikan765mikan765
提出日時 2017-09-05 18:03:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 716 ms
コンパイル使用メモリ 70,912 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:01:27
合計ジャッジ時間 1,489 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#define INF 999999999

using namespace std;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,c,v;
    cin >> n >> c >> v;
    int dp[2*n+1];
    for(int i=0;i<2*n+1;i++){
        dp[i]= INF;
    }
    dp[1]=0;
    for(int i=1;i<=n;i++){
        for(int j=2;j*i<2*n+1;j++){
            dp[i*j]=min(dp[i]+c+v*(j-1),dp[i*j]);
        }
    }
    int ans = dp[n];
    for(int i = n+1;i<2*n+1;i++){
        ans = min(ans,dp[i]);
    }
    cout << ans << endl;
    
}
0