結果

問題 No.376 立方体のN等分 (2)
ユーザー face4
提出日時 2019-02-21 16:57:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 435 ms / 5,000 ms
コード長 417 bytes
コンパイル時間 894 ms
コンパイル使用メモリ 68,124 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-19 00:36:27
合計ジャッジ時間 5,104 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;

    ll ans = n;
    for(ll i = 1; i*i*i <= n; i++){
        if(n%i) continue;
        for(ll j = (ll)sqrt(n/i); j >= 1; j--){
            if((n/i)%j)    continue;
            ans = min(ans, i-1+j-1+(n/i/j)-1);
            break;
        }
    }

    cout << ans << " " << n-1 << endl;

    return 0;
}
0