結果

問題 No.376 立方体のN等分 (2)
ユーザー imulanimulan
提出日時 2019-04-15 00:36:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,742 ms / 5,000 ms
コード長 1,111 bytes
コンパイル時間 1,814 ms
コンパイル使用メモリ 173,412 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 23:56:54
合計ジャッジ時間 14,057 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 93 ms
4,348 KB
testcase_03 AC 90 ms
4,348 KB
testcase_04 AC 106 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 6 ms
4,348 KB
testcase_09 AC 24 ms
4,348 KB
testcase_10 AC 124 ms
4,348 KB
testcase_11 AC 49 ms
4,348 KB
testcase_12 AC 65 ms
4,348 KB
testcase_13 AC 67 ms
4,348 KB
testcase_14 AC 75 ms
4,348 KB
testcase_15 AC 83 ms
4,348 KB
testcase_16 AC 1,515 ms
4,348 KB
testcase_17 AC 93 ms
4,348 KB
testcase_18 AC 95 ms
4,348 KB
testcase_19 AC 99 ms
4,348 KB
testcase_20 AC 100 ms
4,348 KB
testcase_21 AC 1,529 ms
4,348 KB
testcase_22 AC 105 ms
4,348 KB
testcase_23 AC 1,582 ms
4,348 KB
testcase_24 AC 1,527 ms
4,348 KB
testcase_25 AC 108 ms
4,348 KB
testcase_26 AC 1,742 ms
4,348 KB
testcase_27 AC 110 ms
4,348 KB
testcase_28 AC 110 ms
4,348 KB
testcase_29 AC 110 ms
4,348 KB
testcase_30 AC 110 ms
4,348 KB
testcase_31 AC 109 ms
4,348 KB
testcase_32 AC 110 ms
4,348 KB
testcase_33 AC 110 ms
4,348 KB
testcase_34 AC 110 ms
4,348 KB
testcase_35 AC 110 ms
4,348 KB
testcase_36 AC 110 ms
4,348 KB
testcase_37 AC 110 ms
4,348 KB
testcase_38 AC 110 ms
4,348 KB
testcase_39 AC 110 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll INF = LLONG_MAX/3;

vector<ll> divisor(ll n){
    vector<ll> ret;
    for(ll i=1; i*i<=n; ++i){
        if(n%i == 0){
            ret.pb(i);
            if(n/i != i) ret.pb(n/i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    vector<ll> d = divisor(n);
    int D = d.size();

    ll ans = INF;
    rep(i,D){
        ll a = d[i];

        ll x = n/a;
        rep(j,i+1){
            ll b = d[j];
            if(x%b != 0) continue;
            ll c = x/b;

            ans = min(ans, a+b+c-3);
        }
    }

    cout << ans << " " << n-1 << "\n";
    return 0;
}
0