#include #include using namespace std; using LL = long long; using P = pair; using Graph = vector>; const long long LINF = 1LL << 60; #define all(x) (x).begin(), (x).end() #define rep(i,n) for(int i = 0; i < (n); ++i) templatevoid chmin(T&a, T b){if(a > b) a = b;} templatevoid chmax(T&a, T b){if(a < b) a = b;} int main(){ //入力 int N; cin >> N; //配列dpを定義(配列全体を無限大を表す値に初期化) vector 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; }