結果

問題 No.1737 One to N
コンテスト
ユーザー Tannai Ryogo
提出日時 2022-07-16 01:05:47
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 726 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,044 ms
コンパイル使用メモリ 181,584 KB
実行使用メモリ 18,560 KB
最終ジャッジ日時 2026-03-16 04:34:43
合計ジャッジ時間 66,175 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other AC * 10 TLE * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
using LL = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const long long LINF = 1LL << 60;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); ++i)
template<class T>void chmin(T&a, T b){if(a > b) a = b;}
template<class T>void chmax(T&a, T b){if(a < b) a = b;}



int main(){
  //入力
  int N; cin >> N;
  //配列dpを定義(配列全体を無限大を表す値に初期化)
  vector<LL> dp(N+1, LINF);
  //初期条件
  dp[0] = 0;
  dp[1] = 0;

  //ループ
  for(int i = 2; i <= N; ++i){
    for(int j = 1; j < i; ++j){
     if(i%j==0) chmin(dp[i], dp[j]+(i/j));
    }
  }
 cout << dp[N] << endl; 
}
0