結果

問題 No.375 立方体のN等分 (1)
ユーザー bal4ubal4u
提出日時 2019-05-10 22:14:51
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 144 ms / 5,000 ms
コード長 613 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 30,308 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 17:59:52
合計ジャッジ時間 2,500 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 23 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 0 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 17 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 6 ms
4,380 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 6 ms
4,380 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 58 ms
4,376 KB
testcase_15 AC 10 ms
4,376 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 107 ms
4,376 KB
testcase_18 AC 65 ms
4,380 KB
testcase_19 AC 9 ms
4,376 KB
testcase_20 AC 4 ms
4,376 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 144 ms
4,380 KB
testcase_23 AC 7 ms
4,376 KB
testcase_24 AC 4 ms
4,380 KB
testcase_25 AC 20 ms
4,380 KB
testcase_26 AC 6 ms
4,380 KB
testcase_27 AC 10 ms
4,376 KB
testcase_28 AC 4 ms
4,376 KB
testcase_29 AC 4 ms
4,380 KB
testcase_30 AC 6 ms
4,376 KB
testcase_31 AC 8 ms
4,380 KB
testcase_32 AC 4 ms
4,376 KB
testcase_33 AC 7 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: No.375 立方体のN等分 (1)
// 2019.5.10 bal4u

#include <stdio.h>
#include <math.h>

long long comb(long long n) {
	long long max, s;
	int y;
	max = n-1;
	int b = (int)sqrt((double)n);
	for (y = 2; y <= b; y++) {
		if (n%y == 0) {
			s = y + n/y - 2;
			if (s < max) max = s;
		}
	}
	return max;
}

int main()
{
	long long N, max, s;
	int b, x;
	
	scanf("%lld", &N);
	b = (int)sqrt((double)N);
	max = N-1;for (x = 2; x <= b; x++) {
		if (N%x == 0) {
			s = x-1 + comb(N/x); if (s < max) max = s;
			s = N/x-1 + comb(x); if (s < max) max = s;
		}
	}
	printf("%lld %lld\n", max, N-1);
	return 0;
}
0