結果

問題 No.1737 One to N
ユーザー granddaifukugranddaifuku
提出日時 2021-11-18 22:28:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 726 bytes
コンパイル時間 1,352 ms
コンパイル使用メモリ 166,312 KB
実行使用メモリ 42,416 KB
最終ジャッジ日時 2023-08-27 17:01:42
合計ジャッジ時間 3,170 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
42,156 KB
testcase_01 AC 11 ms
42,164 KB
testcase_02 AC 11 ms
42,188 KB
testcase_03 AC 12 ms
42,236 KB
testcase_04 AC 12 ms
42,224 KB
testcase_05 AC 19 ms
42,168 KB
testcase_06 AC 19 ms
42,212 KB
testcase_07 AC 18 ms
42,272 KB
testcase_08 AC 13 ms
42,140 KB
testcase_09 AC 13 ms
42,416 KB
testcase_10 AC 15 ms
42,168 KB
testcase_11 AC 13 ms
42,164 KB
testcase_12 AC 14 ms
42,172 KB
testcase_13 AC 15 ms
42,248 KB
testcase_14 AC 15 ms
42,140 KB
testcase_15 AC 17 ms
42,240 KB
testcase_16 AC 15 ms
42,144 KB
testcase_17 AC 15 ms
42,268 KB
testcase_18 AC 15 ms
42,264 KB
testcase_19 AC 13 ms
42,272 KB
testcase_20 AC 12 ms
42,148 KB
testcase_21 AC 15 ms
42,164 KB
testcase_22 AC 12 ms
42,240 KB
testcase_23 AC 14 ms
42,164 KB
testcase_24 AC 15 ms
42,156 KB
testcase_25 AC 13 ms
42,272 KB
testcase_26 AC 12 ms
42,412 KB
testcase_27 AC 11 ms
42,156 KB
testcase_28 AC 13 ms
42,268 KB
testcase_29 AC 12 ms
42,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

__attribute__((unused)) const ll INF = 1e18;
__attribute__((unused)) const int Inf = 1e9;
__attribute__((unused)) const double EPS = 1e-9;
__attribute__((unused)) const ll MOD = 1000000007;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> dp(1e7, Inf);
  dp[1] = 0;
  FOR(i, 1, n + 1) {
    FOR(j, 1, n + 1) {
      if (i * j > n) break;
      dp[i * j] = min(dp[i * j], dp[i] + j);
    }
  }
  cout << dp[n] << endl;
}
0