結果
| 問題 |
No.375 立方体のN等分 (1)
|
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-05-10 22:44:34 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 5,000 ms |
| コード長 | 583 bytes |
| コンパイル時間 | 133 ms |
| コンパイル使用メモリ | 30,848 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-02 01:03:58 |
| 合計ジャッジ時間 | 1,169 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 |
ソースコード
// yukicoder: No.375 立方体のN等分 (1)
// 2019.5.10 bal4u
#include <stdio.h>
#include <math.h>
long long comb(long long n) {
long long min, s;
int b, y;
min = n-1, b = (int)sqrt((double)n);
for (y = b; y >= 2; y--) {
if (n%y == 0) return y + n/y - 2;
}
return min;
}
int main()
{
long long N, min, s;
int a, b, x;
scanf("%lld", &N);
a = 1+(int)pow((double)N, 1.0/3), b = (int)sqrt((double)N);
min = N-1;for (x = 2; x <= b; x++) if (N%x == 0) {
if (x <= a) b = a;
s = x-1 + comb(N/x); if (s < min) min = s;
}
printf("%lld %lld\n", min, N-1);
return 0;
}
bal4u