結果

問題 No.376 立方体のN等分 (2)
ユーザー kk
提出日時 2021-03-11 22:37:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,056 ms / 5,000 ms
コード長 663 bytes
コンパイル時間 2,664 ms
コンパイル使用メモリ 197,904 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 10:57:05
合計ジャッジ時間 19,158 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 78 ms
5,376 KB
testcase_03 AC 76 ms
5,376 KB
testcase_04 AC 89 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 20 ms
5,376 KB
testcase_10 AC 193 ms
5,376 KB
testcase_11 AC 43 ms
5,376 KB
testcase_12 AC 55 ms
5,376 KB
testcase_13 AC 57 ms
5,376 KB
testcase_14 AC 61 ms
5,376 KB
testcase_15 AC 71 ms
5,376 KB
testcase_16 AC 2,664 ms
5,376 KB
testcase_17 AC 79 ms
5,376 KB
testcase_18 AC 80 ms
5,376 KB
testcase_19 AC 83 ms
5,376 KB
testcase_20 AC 86 ms
5,376 KB
testcase_21 AC 2,667 ms
5,376 KB
testcase_22 AC 88 ms
5,376 KB
testcase_23 AC 2,723 ms
5,376 KB
testcase_24 AC 2,662 ms
5,376 KB
testcase_25 AC 92 ms
5,376 KB
testcase_26 AC 3,056 ms
5,376 KB
testcase_27 AC 101 ms
5,376 KB
testcase_28 AC 93 ms
5,376 KB
testcase_29 AC 93 ms
5,376 KB
testcase_30 AC 94 ms
5,376 KB
testcase_31 AC 91 ms
5,376 KB
testcase_32 AC 92 ms
5,376 KB
testcase_33 AC 92 ms
5,376 KB
testcase_34 AC 94 ms
5,376 KB
testcase_35 AC 94 ms
5,376 KB
testcase_36 AC 93 ms
5,376 KB
testcase_37 AC 95 ms
5,376 KB
testcase_38 AC 93 ms
5,376 KB
testcase_39 AC 92 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

vector<long long> divisor(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i != n / i)
        ret.push_back(n / i);
    }
  }
  return ret;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  long long n;
  cin >> n;

  auto ds = divisor(n);

  long long p = n-1;
  long long q = n-1;
  for (long long x: ds) {
    for (long long y: ds) {
      long long z = n / x / y;
      if (z > 0 && x * y * z == n) {
        p = min(p, x + y + z - 3);
      }
    }
  }

  cout << p << " " << q << endl;
  
  return 0;
}
0