結果

問題 No.375 立方体のN等分 (1)
ユーザー fiord
提出日時 2016-07-16 19:01:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 464 bytes
コンパイル時間 578 ms
コンパイル使用メモリ 63,116 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-15 13:50:27
合計ジャッジ時間 1,820 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15 WA * 17
権限があれば一括ダウンロードができます

ソースコード

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