結果

問題 No.555 世界史のレポート
ユーザー addeight2addeight2
提出日時 2016-08-30 15:13:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 532 bytes
コンパイル時間 1,261 ms
コンパイル使用メモリ 144,188 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-09 02:29:35
合計ジャッジ時間 2,744 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

const int MAX_N=50000;

int N;
int C,V;

int dp[MAX_N*2-1];

void solve(){
  dp[1]=0;
  FOR(i,2,2*N-1){
    dp[i]=C+(i-1)*V;
    for(int j=2;j*j<=i;j++){
      if (i%j==0){
	dp[i]=min(dp[i],dp[j]+C+(i/j-1)*V);
	dp[i]=min(dp[i],dp[i/j]+C+(j-1)*V);
      }
    }
  }
  int ans=dp[N];
  FOR(i,N+1,2*N-1){
    ans=min(ans,dp[i]);
  }
  cout<<ans<<endl;
}

int main(){
  cin>>N;
  cin>>C>>V;
  solve();
  return 0;
}
0