結果

問題 No.376 立方体のN等分 (2)
ユーザー Tsuneo YoshiokaTsuneo Yoshioka
提出日時 2016-06-05 00:07:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3,589 ms / 5,000 ms
コード長 761 bytes
コンパイル時間 718 ms
コンパイル使用メモリ 63,532 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-06 18:54:48
合計ジャッジ時間 24,251 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 238 ms
4,384 KB
testcase_03 AC 471 ms
4,376 KB
testcase_04 AC 483 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 9 ms
4,380 KB
testcase_09 AC 35 ms
4,380 KB
testcase_10 AC 499 ms
4,376 KB
testcase_11 AC 121 ms
4,376 KB
testcase_12 AC 184 ms
4,508 KB
testcase_13 AC 112 ms
4,380 KB
testcase_14 AC 148 ms
4,376 KB
testcase_15 AC 87 ms
4,380 KB
testcase_16 AC 2,742 ms
4,380 KB
testcase_17 AC 167 ms
4,376 KB
testcase_18 AC 98 ms
4,376 KB
testcase_19 AC 323 ms
4,380 KB
testcase_20 AC 128 ms
4,380 KB
testcase_21 AC 3,284 ms
4,376 KB
testcase_22 AC 105 ms
4,380 KB
testcase_23 AC 3,589 ms
4,384 KB
testcase_24 AC 3,543 ms
4,380 KB
testcase_25 AC 106 ms
4,380 KB
testcase_26 AC 3,478 ms
4,380 KB
testcase_27 AC 177 ms
4,380 KB
testcase_28 AC 106 ms
4,376 KB
testcase_29 AC 283 ms
4,376 KB
testcase_30 AC 179 ms
4,380 KB
testcase_31 AC 105 ms
4,380 KB
testcase_32 AC 178 ms
4,380 KB
testcase_33 AC 106 ms
4,380 KB
testcase_34 AC 106 ms
4,380 KB
testcase_35 AC 229 ms
4,380 KB
testcase_36 AC 105 ms
4,376 KB
testcase_37 AC 105 ms
4,376 KB
testcase_38 AC 244 ms
4,376 KB
testcase_39 AC 219 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <climits>

using namespace std;
typedef long long ll;

int main(void){
    // Here your code !
    ll N;
    ll mi = LLONG_MAX;
    ll bestc = -1;
    cin >> N;
    for(ll a=1;a*a*a<=N;a++){
        if(N%a!=0){
            continue;
        }
        ll M = N/a;
        ll startb = a;
        if(bestc != -1 && M>=bestc && M%bestc==0){
            startb = max(startb, M/bestc);
        }
        for(ll b=startb;b*b<=M;b++){
            if(M%b!=0){
                continue;
            }
            ll c = M/b;
            ll total = (a-1)+(b-1)+(c-1);
            if(total < mi){
                bestc = c;
                mi = total;
            }
        }        
    }
    cout << mi << " " << N-1 << endl;
    return 0;
}
0