結果

問題 No.555 世界史のレポート
ユーザー nanophoto12nanophoto12
提出日時 2017-08-16 15:00:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,132 bytes
コンパイル時間 859 ms
コンパイル使用メモリ 90,668 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 14:10:46
合計ジャッジ時間 2,252 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 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 52 ms
5,376 KB
testcase_11 AC 59 ms
5,376 KB
testcase_12 AC 52 ms
5,376 KB
testcase_13 AC 42 ms
5,376 KB
testcase_14 AC 56 ms
5,376 KB
testcase_15 AC 58 ms
5,376 KB
testcase_16 AC 46 ms
5,376 KB
testcase_17 AC 53 ms
5,376 KB
testcase_18 AC 59 ms
5,376 KB
testcase_19 AC 83 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> t3;

ll dp[100010];

int main()
{
    int n, c, v;
    cin >> n >> c >> v;
    fill(dp, dp + 100010, 1e7);
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = c + v;
    for(int i = 3;i < 2 * n;i++)
    {
        dp[i] = dp[1] + c + v * (i-1);
        for(int j = 2;j * j <= i;j++)
        {
            if(i % j == 0)
            {
                int j2 = i / j;
                if(j2 < i)
                {
                    dp[i] = min(dp[i], dp[j] + c + v * (j2 - 1));
                    dp[i] = min(dp[i], dp[j2] + c + v * (j - 1));
                }
            }
        }
    }
    ll m = 1e10;
    for(int i = n;i <= 2 * n;i++)
    {
        m = min(m, dp[i]);
    }
    cout << m << endl;
    return 0;
}
0