結果

問題 No.375 立方体のN等分 (1)
ユーザー motimoti
提出日時 2016-06-04 23:39:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,572 bytes
コンパイル時間 1,294 ms
コンパイル使用メモリ 115,788 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-17 01:35:05
合計ジャッジ時間 11,396 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  ll N; cin >> N;

  ll INF = std::numeric_limits<ll>::max();
  ll ans = INF;

  vector<ll> vs;
  for(int i=1; (ll)i*i<=N; i++) {
    if(N % i == 0) {
      vs.push_back(i);
    }
  }

  int M = vs.size();

  REP(i, 1, min(800, M))
  REP(j, 1, min(800, M))
  REP(k, 1, min(800, M))
  if(N % vs[i] == 0 && N % vs[j] == 0 && N % vs[k] == 0) {
    rep(a, 2) rep(b, 2) rep(c, 2) {
      ll ni = a ? vs[i] : N / vs[i];
      ll nj = b ? vs[j] : N / vs[j];
      ll nk = c ? vs[k] : N / vs[k];
      if(ni * nj * nk == N) {
        minimize(ans, ni + nj + nk - 3);
      }
    }
  }

  cout << (ans == INF ? N - 1 : ans) << " " << N - 1 << endl;

  return 0;
}
0