結果

問題 No.555 世界史のレポート
ユーザー ikdikd
提出日時 2017-08-12 01:47:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 665 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 61,572 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 00:34:04
合計ジャッジ時間 1,834 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 61 ms
6,940 KB
testcase_11 AC 73 ms
6,940 KB
testcase_12 AC 64 ms
6,940 KB
testcase_13 AC 55 ms
6,940 KB
testcase_14 AC 73 ms
6,940 KB
testcase_15 AC 72 ms
6,944 KB
testcase_16 AC 59 ms
6,940 KB
testcase_17 AC 68 ms
6,944 KB
testcase_18 AC 76 ms
6,940 KB
testcase_19 AC 105 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>

using namespace std;
#define repeat(i,n) for(int i=0;i<(n);i++)

vector<int> f(int n){
   vector<int> rt;
   int i=1;
   while(i*i<=n){
      if(n%i==0){
         rt.push_back(i);
         rt.push_back(n/i);
      }
      i++;
   }
   return rt;
}

int main(){

   int n; cin>> n;
   int c, v;
   cin>> c>> v;

   vector<int> dp(2*n, 100000008);
   dp[0]=dp[1]=0;
   for(int i=2; i<dp.size(); i++){
      auto dd=f(i);
      for(int d: dd){
         int r=(i-d+d-1)/d;
         dp[i]=min(dp[i], dp[d]+c+r*v);
      }
   }

   int mi=100000008;
   for(int i=n; i<2*n; i++) mi=min(mi, dp[i]);
   cout<< mi<< endl;

   return 0;
}
0