結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 91 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 217 ms
4,348 KB
testcase_11 AC 49 ms
4,348 KB
testcase_12 AC 65 ms
4,348 KB
testcase_13 AC 68 ms
4,348 KB
testcase_14 AC 75 ms
4,348 KB
testcase_15 AC 84 ms
4,348 KB
testcase_16 AC 2,951 ms
4,348 KB
testcase_17 AC 92 ms
4,348 KB
testcase_18 AC 96 ms
4,348 KB
testcase_19 AC 98 ms
4,348 KB
testcase_20 AC 102 ms
4,348 KB
testcase_21 AC 2,965 ms
4,348 KB
testcase_22 AC 105 ms
4,348 KB
testcase_23 AC 3,055 ms
4,348 KB
testcase_24 AC 2,955 ms
4,348 KB
testcase_25 AC 108 ms
4,348 KB
testcase_26 AC 3,378 ms
4,348 KB
testcase_27 AC 109 ms
4,348 KB
testcase_28 AC 110 ms
4,348 KB
testcase_29 AC 111 ms
4,348 KB
testcase_30 AC 110 ms
4,348 KB
testcase_31 AC 110 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 111 ms
4,348 KB
testcase_37 AC 111 ms
4,348 KB
testcase_38 AC 110 ms
4,348 KB
testcase_39 AC 111 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,D){
            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