結果

問題 No.376 立方体のN等分 (2)
ユーザー hanorverhanorver
提出日時 2016-06-05 09:14:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,052 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 68,072 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 04:23:18
合計ジャッジ時間 9,115 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 254 ms
5,376 KB
testcase_04 WA -
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 10 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 160 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 116 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 131 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 164 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 141 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 142 ms
5,376 KB
testcase_26 WA -
testcase_27 AC 209 ms
5,376 KB
testcase_28 AC 144 ms
5,376 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 143 ms
5,376 KB
testcase_32 AC 209 ms
5,376 KB
testcase_33 AC 142 ms
5,376 KB
testcase_34 AC 143 ms
5,376 KB
testcase_35 AC 201 ms
5,376 KB
testcase_36 AC 143 ms
5,376 KB
testcase_37 AC 144 ms
5,376 KB
testcase_38 AC 249 ms
5,376 KB
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void factor(long long n, std::vector<long long> &v) {
	v.push_back(1);
	if (n % 2 == 0) {
		v.push_back(2);
		while (n % 2 == 0) n /= 2;
	}
	if (n % 3 == 0) {
		v.push_back(3);
		while (n % 3 == 0) n /= 3;
	}
	if (n % 5 == 0) {
		v.push_back(5);
		while (n % 5 == 0) n /= 5;
	}

	long long end = sqrt(n);
	for (long long i = 6; i <= end; i+=6) {
		if (n % (i - 1) == 0) {
			v.push_back(i - 1);
			while (n % (i - 1) == 0) n /= (i - 1);
		}
		if (n % (i + 1) == 0) {
			v.push_back(i + 1);
			while (n % (i + 1) == 0) n /= (i + 1);
		}
	}
}

int main() {
	long long n;

	std::cin >> n;

	long long max = n - 1, min = n - 1;

	long long a, b, c;

	std::vector<long long> v;

	factor(n, v);

	for (long long i : v) {
		if (i * i * i > n) break;
		if (n % i != 0) continue;
		long long tn = n / i;
		for (long long j = i; j * j <= tn; j++) {
			if (tn % j != 0) continue;
			min = std::min(min, i + j + tn / j - 3);
		}
	}

	std::cout << min << " " << max << std::endl;
	return 0;
}
0