結果

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

テストケース

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

ソースコード

diff #

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