結果

問題 No.376 立方体のN等分 (2)
ユーザー fiordfiord
提出日時 2016-07-16 19:05:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4,654 ms / 5,000 ms
コード長 475 bytes
コンパイル時間 423 ms
コンパイル使用メモリ 63,032 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 13:49:41
合計ジャッジ時間 29,144 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 316 ms
5,248 KB
testcase_03 AC 690 ms
5,376 KB
testcase_04 AC 454 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 8 ms
5,376 KB
testcase_09 AC 32 ms
5,376 KB
testcase_10 AC 589 ms
5,376 KB
testcase_11 AC 111 ms
5,376 KB
testcase_12 AC 276 ms
5,376 KB
testcase_13 AC 104 ms
5,376 KB
testcase_14 AC 138 ms
5,376 KB
testcase_15 AC 78 ms
5,376 KB
testcase_16 AC 3,788 ms
5,376 KB
testcase_17 AC 273 ms
5,376 KB
testcase_18 AC 92 ms
5,376 KB
testcase_19 AC 544 ms
5,376 KB
testcase_20 AC 115 ms
5,376 KB
testcase_21 AC 4,191 ms
5,376 KB
testcase_22 AC 93 ms
6,944 KB
testcase_23 AC 4,442 ms
6,940 KB
testcase_24 AC 4,469 ms
6,940 KB
testcase_25 AC 93 ms
6,944 KB
testcase_26 AC 4,654 ms
6,944 KB
testcase_27 AC 162 ms
6,940 KB
testcase_28 AC 95 ms
6,940 KB
testcase_29 AC 258 ms
6,940 KB
testcase_30 AC 169 ms
6,944 KB
testcase_31 AC 94 ms
6,944 KB
testcase_32 AC 161 ms
6,940 KB
testcase_33 AC 93 ms
6,940 KB
testcase_34 AC 97 ms
6,944 KB
testcase_35 AC 206 ms
6,944 KB
testcase_36 AC 95 ms
6,940 KB
testcase_37 AC 97 ms
6,944 KB
testcase_38 AC 218 ms
6,944 KB
testcase_39 AC 249 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
	ll n;	cin >> n;
	//(a+1)(b+1)(c+1)=Nを満たす中でのa+b+cの最小値
	ll ans = 1e15;
	for (ll a = ceil(cbrt(n)); a > 0; a--) {
		if (n%a != 0)	continue;
		ll left = n / a;
		for (ll b = sqrt(left); b > 0; b--) {
			if (left%b != 0)	continue;
			ll c = left / b;
			ans = min(a + b + c - 3, ans);
		}
	}
	cout << ans << " " << n - 1 << endl;
	return 0;
}
0