結果

問題 No.375 立方体のN等分 (1)
ユーザー GrenacheGrenache
提出日時 2016-06-08 20:07:29
言語 Java19
(openjdk 21)
結果
AC  
実行時間 148 ms / 5,000 ms
コード長 1,051 bytes
コンパイル時間 3,470 ms
コンパイル使用メモリ 75,596 KB
実行使用メモリ 56,588 KB
最終ジャッジ日時 2023-08-02 01:41:10
合計ジャッジ時間 9,121 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
56,192 KB
testcase_01 AC 114 ms
56,588 KB
testcase_02 AC 135 ms
55,924 KB
testcase_03 AC 117 ms
56,236 KB
testcase_04 AC 114 ms
55,872 KB
testcase_05 AC 117 ms
55,976 KB
testcase_06 AC 114 ms
56,164 KB
testcase_07 AC 120 ms
56,360 KB
testcase_08 AC 128 ms
56,132 KB
testcase_09 AC 122 ms
56,228 KB
testcase_10 AC 125 ms
56,108 KB
testcase_11 AC 124 ms
55,952 KB
testcase_12 AC 123 ms
55,900 KB
testcase_13 AC 121 ms
56,472 KB
testcase_14 AC 147 ms
56,416 KB
testcase_15 AC 122 ms
56,120 KB
testcase_16 AC 125 ms
56,344 KB
testcase_17 AC 147 ms
56,260 KB
testcase_18 AC 143 ms
55,828 KB
testcase_19 AC 125 ms
56,076 KB
testcase_20 AC 125 ms
56,156 KB
testcase_21 AC 123 ms
56,284 KB
testcase_22 AC 148 ms
55,892 KB
testcase_23 AC 128 ms
56,224 KB
testcase_24 AC 124 ms
55,680 KB
testcase_25 AC 127 ms
53,996 KB
testcase_26 AC 127 ms
56,120 KB
testcase_27 AC 125 ms
56,380 KB
testcase_28 AC 129 ms
56,088 KB
testcase_29 AC 122 ms
56,136 KB
testcase_30 AC 123 ms
56,360 KB
testcase_31 AC 122 ms
56,304 KB
testcase_32 AC 123 ms
56,000 KB
testcase_33 AC 131 ms
55,776 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