結果
| 問題 |
No.1737 One to N
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-24 13:46:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 2,000 ms |
| コード長 | 518 bytes |
| コンパイル時間 | 1,872 ms |
| コンパイル使用メモリ | 195,256 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-24 13:46:19 |
| 合計ジャッジ時間 | 3,240 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
#define rep(i, n) for(int i =0; i < (n); i++)
using ll = long long int;
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("input.txt", "r", stdin);
int n; cin >> n;
vector<int> dp(n+1, 1e9);
dp[1] = 0;
for (int i = 1; i <= n; i++) {
if (dp[i] == 1e9) continue;
for (int k = 2; i*k <= n; k++) {
dp[i*k] = min(dp[i*k], dp[i] + k);
}
}
cout << dp[n] << endl;
return 0;
}