結果

問題 No.375 立方体のN等分 (1)
ユーザー sten_sansten_san
提出日時 2021-01-31 14:49:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,371 bytes
コンパイル時間 2,390 ms
コンパイル使用メモリ 205,608 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 08:56:33
合計ジャッジ時間 4,254 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,384 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 4 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 3 ms
4,384 KB
testcase_29 AC 5 ms
4,380 KB
testcase_30 AC 4 ms
4,380 KB
testcase_31 AC 3 ms
4,376 KB
testcase_32 AC 5 ms
4,380 KB
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

struct uns_t {} uns;
template <typename Element, typename Head, typename ...Args>
auto vec(Element init, Head arg, Args ...args) {
    if constexpr (sizeof...(Args) == 0) return std::vector(arg, init);
    else return std::vector(arg, vec(init, args...));
}
template <typename Element, typename Head, typename ...Args>
auto vec(uns_t, Head arg, Args ...args) {
    return vec(Element(), arg, args...);
}

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

    auto prime_factor = [](int64_t n) {
        auto p = vec<array<int64_t, 2>>(uns, 0);
        for (int64_t i = 2; i * i <= n; ++i) {
            if (n % i) continue;
            int cnt = 0;
            while (n % i == 0) {
                n /= i;
                ++cnt;
            }
            p.push_back({ i, cnt });
        }
        if (n != 1) {
            p.push_back({ n, 1 });
        }
        return p;
    };

    priority_queue<int64_t, vector<int64_t>, greater<int64_t>> que;
    que.push(1);
    que.push(1);
    que.push(1);
    for (auto [a, b] : prime_factor(n)) {
        while (b--) {
            auto m = que.top(); que.pop();
            m *= a;
            que.push(m);
        }
    }

    auto a = que.top(); que.pop();
    auto b = que.top(); que.pop();
    auto c = que.top(); que.pop();

    cout << (a + b + c - 3) << ' ' << (n - 1) << endl;
}

0