結果

問題 No.375 立方体のN等分 (1)
ユーザー masamasa
提出日時 2016-06-05 00:13:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 892 bytes
コンパイル時間 719 ms
コンパイル使用メモリ 74,976 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-17 03:23:42
合計ジャッジ時間 2,161 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 WA -
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 4 ms
6,940 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 5 ms
6,944 KB
testcase_21 AC 5 ms
6,940 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 5 ms
6,944 KB
testcase_25 AC 6 ms
6,940 KB
testcase_26 AC 5 ms
6,940 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 5 ms
6,940 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 5 ms
6,944 KB
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>
#include <cmath>

using namespace std;

vector<long long> get_yakusu(long long n) {
	set<long long> yakusu_set;
	long long limit = sqrt(n);
	for (int i = 1; i <= limit; i++) {
		if (n % i == 0) {
			yakusu_set.insert(i);
			yakusu_set.insert(n / i);
		}
	}

	vector<long long> yakusu(yakusu_set.begin(), yakusu_set.end());
	return yakusu;
}


int main() {
	long long n;

	cin >> n;

	long long tmin, tmax;
	tmax = n - 1;
	tmin = tmax;

	auto yakusu = get_yakusu(n);
	int len = yakusu.size();
	long long x, y, z;
	for (int i = 0; i < len; i++) {
		x = yakusu[i];
		for (int j = 0; j < len; j++) {
			y = yakusu[j];
			z = n / x / y;
			if (z == 0) {
				continue;
			}
			tmin = min(tmin, x + y + z - 3);
		}
	}

	cout << tmin << " " << tmax << endl;
	return 0;
}
0