結果

問題 No.376 立方体のN等分 (2)
ユーザー finefine
提出日時 2016-06-05 02:10:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 118 ms / 5,000 ms
コード長 837 bytes
コンパイル時間 1,669 ms
コンパイル使用メモリ 171,060 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-06 19:01:32
合計ジャッジ時間 6,162 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 80 ms
4,380 KB
testcase_03 AC 76 ms
4,376 KB
testcase_04 AC 91 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 20 ms
4,380 KB
testcase_10 AC 29 ms
4,376 KB
testcase_11 AC 42 ms
4,380 KB
testcase_12 AC 56 ms
4,380 KB
testcase_13 AC 59 ms
4,380 KB
testcase_14 AC 65 ms
4,380 KB
testcase_15 AC 72 ms
4,380 KB
testcase_16 AC 98 ms
4,376 KB
testcase_17 AC 80 ms
4,380 KB
testcase_18 AC 84 ms
4,380 KB
testcase_19 AC 85 ms
4,380 KB
testcase_20 AC 88 ms
4,380 KB
testcase_21 AC 108 ms
4,376 KB
testcase_22 AC 91 ms
4,376 KB
testcase_23 AC 113 ms
4,380 KB
testcase_24 AC 114 ms
4,380 KB
testcase_25 AC 94 ms
4,380 KB
testcase_26 AC 118 ms
4,380 KB
testcase_27 AC 95 ms
4,380 KB
testcase_28 AC 95 ms
4,380 KB
testcase_29 AC 95 ms
4,380 KB
testcase_30 AC 95 ms
4,380 KB
testcase_31 AC 96 ms
4,376 KB
testcase_32 AC 95 ms
4,376 KB
testcase_33 AC 95 ms
4,384 KB
testcase_34 AC 95 ms
4,380 KB
testcase_35 AC 96 ms
4,380 KB
testcase_36 AC 95 ms
4,380 KB
testcase_37 AC 95 ms
4,380 KB
testcase_38 AC 96 ms
4,376 KB
testcase_39 AC 96 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;

vector<ull> divisor(ull n) {
    vector<ull> res;
    for (ull i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.emplace_back(i);
            res.emplace_back(n / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ull n;
    cin >> n;
    ull tmax = n - 1;
    ull tmin = tmax;
    vector<ull> d = divisor(n);
    for (int i = 0; d[i] * d[i] * d[i] <= n; i++) {
        ull tmp = n / d[i];
        for (int j = d.size() - 1; j >= 0; j--) {
            if (d[j] * d[j] > tmp || tmp % d[j]) continue;
            tmin = min(tmin, d[i] + d[j] + tmp / d[j] - 3);
            break;
        }
    }
    cout << tmin << " " << tmax << "\n";
    return 0;
}
0