結果

問題 No.375 立方体のN等分 (1)
ユーザー fiordfiord
提出日時 2016-07-16 19:02:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 474 bytes
コンパイル時間 580 ms
コンパイル使用メモリ 62,348 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 13:48:48
合計ジャッジ時間 1,925 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 22 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 15 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 7 ms
5,376 KB
testcase_11 AC 6 ms
5,376 KB
testcase_12 AC 8 ms
5,376 KB
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 51 ms
5,376 KB
testcase_15 AC 11 ms
5,376 KB
testcase_16 AC 8 ms
5,376 KB
testcase_17 AC 85 ms
5,376 KB
testcase_18 AC 56 ms
5,376 KB
testcase_19 AC 10 ms
5,376 KB
testcase_20 AC 5 ms
5,376 KB
testcase_21 AC 5 ms
5,376 KB
testcase_22 AC 110 ms
5,376 KB
testcase_23 WA -
testcase_24 AC 5 ms
5,376 KB
testcase_25 AC 20 ms
5,376 KB
testcase_26 AC 8 ms
5,376 KB
testcase_27 AC 10 ms
5,376 KB
testcase_28 AC 5 ms
5,376 KB
testcase_29 AC 5 ms
5,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 8 ms
5,376 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 = 1e9;
	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