結果

問題 No.376 立方体のN等分 (2)
ユーザー GrenacheGrenache
提出日時 2016-06-08 20:07:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 345 ms / 5,000 ms
コード長 1,051 bytes
コンパイル時間 3,146 ms
コンパイル使用メモリ 79,212 KB
実行使用メモリ 42,460 KB
最終ジャッジ日時 2024-04-24 15:01:02
合計ジャッジ時間 12,566 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
40,968 KB
testcase_01 AC 118 ms
41,124 KB
testcase_02 AC 207 ms
40,848 KB
testcase_03 AC 205 ms
41,552 KB
testcase_04 AC 216 ms
41,420 KB
testcase_05 AC 119 ms
41,120 KB
testcase_06 AC 112 ms
41,372 KB
testcase_07 AC 110 ms
40,132 KB
testcase_08 AC 127 ms
41,488 KB
testcase_09 AC 127 ms
40,444 KB
testcase_10 AC 173 ms
41,192 KB
testcase_11 AC 164 ms
41,432 KB
testcase_12 AC 178 ms
40,384 KB
testcase_13 AC 186 ms
41,248 KB
testcase_14 AC 193 ms
41,076 KB
testcase_15 AC 179 ms
39,952 KB
testcase_16 AC 318 ms
42,420 KB
testcase_17 AC 215 ms
41,120 KB
testcase_18 AC 197 ms
40,436 KB
testcase_19 AC 211 ms
41,164 KB
testcase_20 AC 212 ms
41,216 KB
testcase_21 AC 340 ms
42,360 KB
testcase_22 AC 206 ms
40,460 KB
testcase_23 AC 342 ms
42,460 KB
testcase_24 AC 345 ms
42,184 KB
testcase_25 AC 214 ms
40,832 KB
testcase_26 AC 343 ms
42,256 KB
testcase_27 AC 225 ms
41,048 KB
testcase_28 AC 216 ms
40,224 KB
testcase_29 AC 215 ms
40,388 KB
testcase_30 AC 231 ms
40,952 KB
testcase_31 AC 223 ms
41,084 KB
testcase_32 AC 216 ms
40,296 KB
testcase_33 AC 229 ms
41,016 KB
testcase_34 AC 225 ms
40,360 KB
testcase_35 AC 216 ms
40,368 KB
testcase_36 AC 223 ms
41,396 KB
testcase_37 AC 209 ms
40,268 KB
testcase_38 AC 222 ms
41,160 KB
testcase_39 AC 230 ms
41,516 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