結果

問題 No.375 立方体のN等分 (1)
ユーザー odan3240odan3240
提出日時 2016-06-06 21:03:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,157 bytes
コンパイル時間 698 ms
コンパイル使用メモリ 76,840 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 05:20:14
合計ジャッジ時間 1,716 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 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 1 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 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 WA -
testcase_26 AC 4 ms
5,376 KB
testcase_27 WA -
testcase_28 AC 3 ms
5,376 KB
testcase_29 AC 4 ms
5,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<int> f(ll N) {
    vector<int> vs;
    for (ll i = 2; i * i <= N; i++) {
        while (N % i == 0) {
            vs.push_back(i);
            N /= i;
        }
    }
    if (N != 1) vs.push_back(N);
    return vs;
}

int main() {
    ll N;
    cin >> N;
    auto vs = f(N);
    ll t[3] = {1, 1, 1};
    rep(i, 3) {
        if (i < vs.size()) t[i] = vs[i];
    }
    for (int i = 3; i < vs.size() / 3; i += 3) {
        t[0] *= vs[i];
        t[1] *= vs[i + 1];
        t[2] *= vs[i + 2];
    }
    ll ans = (t[0] - 1) + (t[1] - 1) + (t[2] - 1);
    cout << ans << " " << N - 1 << endl;
    return 0;
}
0