結果

問題 No.376 立方体のN等分 (2)
ユーザー kapokapo
提出日時 2016-06-09 21:27:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 495 ms / 5,000 ms
コード長 774 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 65,448 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 15:01:12
合計ジャッジ時間 6,176 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 84 ms
5,376 KB
testcase_03 AC 76 ms
5,376 KB
testcase_04 AC 98 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 21 ms
5,376 KB
testcase_10 AC 54 ms
5,376 KB
testcase_11 AC 42 ms
5,376 KB
testcase_12 AC 58 ms
5,376 KB
testcase_13 AC 62 ms
5,376 KB
testcase_14 AC 67 ms
5,376 KB
testcase_15 AC 74 ms
5,376 KB
testcase_16 AC 434 ms
5,376 KB
testcase_17 AC 80 ms
5,376 KB
testcase_18 AC 82 ms
5,376 KB
testcase_19 AC 86 ms
5,376 KB
testcase_20 AC 90 ms
5,376 KB
testcase_21 AC 440 ms
5,376 KB
testcase_22 AC 91 ms
5,376 KB
testcase_23 AC 464 ms
5,376 KB
testcase_24 AC 453 ms
5,376 KB
testcase_25 AC 97 ms
5,376 KB
testcase_26 AC 495 ms
5,376 KB
testcase_27 AC 93 ms
5,376 KB
testcase_28 AC 97 ms
5,376 KB
testcase_29 AC 97 ms
5,376 KB
testcase_30 AC 109 ms
5,376 KB
testcase_31 AC 100 ms
5,376 KB
testcase_32 AC 99 ms
5,376 KB
testcase_33 AC 99 ms
5,376 KB
testcase_34 AC 96 ms
5,376 KB
testcase_35 AC 97 ms
5,376 KB
testcase_36 AC 98 ms
5,376 KB
testcase_37 AC 99 ms
5,376 KB
testcase_38 AC 97 ms
5,376 KB
testcase_39 AC 99 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define ll long long
using namespace std; 

ll N;
vector<ll> V;

void divisor(void)
{
	for(ll i=2; i*i <= N; i++) {
		if(N%i == 0) {
			V.pb(i);
			if(i*i != N) V.pb(N/i);
		}
	}
}

int main(void)
{
	cin >> N;
	ll max = N-1;
	ll min = N-1;

	divisor();

	// for(auto i:V) cout << i << " ";	cout << endl;

	sort(all(V));
	rep(i,0,V.size()){
		if(min < V[i] *2 -3) break;
		rep(j,i,V.size()) {
			ll t = V[i] * V[j];
			if(N < t) break;
			if(N % t) continue;
			// printf("V[i]=%lld V[j]=%lld t=%lld\n",V[i],V[j],t);
			min = std::min(min, V[i]+V[j]+(N/t)-3);
		}
	}

	cout << min << " " << max << endl;

	return 0;
}
0