結果

問題 No.376 立方体のN等分 (2)
ユーザー pekempeypekempey
提出日時 2016-06-04 23:39:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 638 bytes
コンパイル時間 1,919 ms
コンパイル使用メモリ 162,300 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 01:34:05
合計ジャッジ時間 4,776 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 89 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 10 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 51 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 56 ms
5,376 KB
testcase_14 AC 72 ms
5,376 KB
testcase_15 AC 87 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 98 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 97 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 96 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
5,376 KB
testcase_26 WA -
testcase_27 AC 177 ms
5,376 KB
testcase_28 AC 104 ms
5,376 KB
testcase_29 AC 106 ms
5,376 KB
testcase_30 WA -
testcase_31 AC 84 ms
5,376 KB
testcase_32 AC 32 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 54 ms
5,376 KB
testcase_35 AC 156 ms
5,376 KB
testcase_36 AC 209 ms
5,376 KB
testcase_37 AC 208 ms
5,376 KB
testcase_38 AC 133 ms
5,376 KB
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<long long> divisors(long long n) {
	vector<long long> result;
	long long m = sqrt(n);
	for (long long i = m; i >= 1; i--) if (n % i == 0) {
		result.push_back(i);
		if (i != n / i) result.push_back(n / i);
		return result;
	}
	return result;
}

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

	long long mx = n - 1;
	long long mn = 1e18;
	for (long long p : divisors(n)) {
		long long qr = n / p;
		for (long long q : divisors(qr)) {
			long long r = qr / q;
			long long num = (p - 1) + (q - 1) + (r - 1);
			mx = max(mx, num);
			mn = min(mn, num);
		}
	}
	cout << mn << " " << mx << endl;
}
0