結果

問題 No.375 立方体のN等分 (1)
ユーザー GrenacheGrenache
提出日時 2016-06-08 20:07:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 141 ms / 5,000 ms
コード長 1,051 bytes
コンパイル時間 3,135 ms
コンパイル使用メモリ 79,088 KB
実行使用メモリ 54,688 KB
最終ジャッジ日時 2024-04-20 02:13:23
合計ジャッジ時間 8,132 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
54,228 KB
testcase_01 AC 114 ms
53,072 KB
testcase_02 AC 130 ms
54,172 KB
testcase_03 AC 103 ms
53,120 KB
testcase_04 AC 114 ms
54,392 KB
testcase_05 AC 109 ms
54,148 KB
testcase_06 AC 110 ms
54,160 KB
testcase_07 AC 115 ms
53,556 KB
testcase_08 AC 126 ms
53,656 KB
testcase_09 AC 117 ms
53,992 KB
testcase_10 AC 119 ms
53,284 KB
testcase_11 AC 120 ms
54,136 KB
testcase_12 AC 123 ms
54,304 KB
testcase_13 AC 108 ms
53,080 KB
testcase_14 AC 138 ms
53,564 KB
testcase_15 AC 124 ms
54,092 KB
testcase_16 AC 112 ms
53,280 KB
testcase_17 AC 133 ms
53,468 KB
testcase_18 AC 128 ms
53,652 KB
testcase_19 AC 124 ms
54,236 KB
testcase_20 AC 123 ms
53,156 KB
testcase_21 AC 121 ms
54,036 KB
testcase_22 AC 141 ms
54,688 KB
testcase_23 AC 108 ms
53,248 KB
testcase_24 AC 126 ms
54,240 KB
testcase_25 AC 126 ms
54,344 KB
testcase_26 AC 127 ms
54,052 KB
testcase_27 AC 124 ms
53,536 KB
testcase_28 AC 123 ms
53,320 KB
testcase_29 AC 119 ms
54,124 KB
testcase_30 AC 122 ms
54,460 KB
testcase_31 AC 110 ms
53,428 KB
testcase_32 AC 104 ms
52,964 KB
testcase_33 AC 121 ms
54,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;


public class Main_yukicoder375 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();

        List<Long> divisors = new ArrayList<>();
        for (long i = 1; i * i <= n; i++) {
        	if (n % i == 0) {
        		divisors.add(i);
        		if (i != n / i) {
        			divisors.add(n / i);
        		}
        	}
        }
        Collections.sort(divisors);

        long min = n - 1;
        long max = n - 1;
        for (int i = 0; i < divisors.size(); i++) {
    		long x = divisors.get(i);
    		if (x * x * x > n) {
    			break;
    		}
        	for (int j = i; j < divisors.size(); j++) {
        		long y = divisors.get(j);
        		if (x * y * y > n) {
        			break;
        		}
        		if (n % (x * y) != 0) {
        			continue;
        		}
        		long z = n / (x * y);

        		min = Math.min(min, (x - 1) + (y - 1) + (z - 1));
        	}
        }

        System.out.printf("%d %d\n", min, max);

        sc.close();
    }
}
0