結果

問題 No.375 立方体のN等分 (1)
ユーザー siguma323siguma323
提出日時 2016-06-05 00:27:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,541 bytes
コンパイル時間 1,747 ms
コンパイル使用メモリ 169,220 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 03:28:52
合計ジャッジ時間 2,671 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

using ull = unsigned long long;
using ll = long long;

int main()
{
    ull N;
    cin >> N;

    ll num1 = 1;
    ll num2= 1;
    ll num3 = 1;
    ll count = num1*num2*num3;

    // if(N&1)
    // {
        map<int,int> res;

        ll tmp = N;
        for(ll i = 2; i*i <= tmp; ++i)
        {
            while(tmp % i == 0)
            {
                ++res[i];
                tmp /= i;
            }
        }

        if(tmp != 1) res[tmp] = 1;

        int index = 1;
        for(auto&& x : res)
        {
            for(int i = 0; i < x.second; ++i)
            {
                if(index == 1)
                {
                    num1 *= x.first;
                    index = 2;
                }
                else if(index == 2)
                {
                    num2 *= x.first;
                    index = 3;
                }
                else
                {
                    num3 *= x.first;
                    index = 1;
                }
            }
        }
        count = num1*num2*num3;
    // }
    // else
    // {
    //     while(count != N && count < N)
    //     {
    //         if(num1 == num3)
    //             ++num1;
    //         else if(num2 == num3)
    //             ++num2;
    //         else
    //             ++num3;
    //         count = num1*num2*num3;
    //     }
    // }

    if(count != N)
        cout << N-1 << ' ' << N-1 << endl;
    else
        cout << (num1-1) + (num2-1) + (num3-1) << ' ' <<  N-1 << endl;

}
0