結果
問題 | No.1737 One to N |
ユーザー |
|
提出日時 | 2022-09-24 12:30:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 615 bytes |
コンパイル時間 | 1,501 ms |
コンパイル使用メモリ | 167,680 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2024-12-22 05:54:54 |
合計ジャッジ時間 | 3,245 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;#define all(a) begin(a), end(a)#define sz(x) (int)((x).size())#ifdef LOCAL#include "debug.hpp"#else#define debug(...) 42#endifconst int N = 3e5 + 10;ll dp[N];void init() {memset(dp, 0x3f, sizeof dp);dp[1] = 0;for (int i = 2; i < N; i++) {for (int j = i; j < N; j += i) {dp[j] = min(dp[j], dp[j / i] + i);}}}void solve() {int n; cin >> n;cout << dp[n] << '\n';}int main() {cin.tie(nullptr)->sync_with_stdio(false);init();int T = 1;// cin >> T;while (T--) solve();return 0;}