結果

問題 No.375 立方体のN等分 (1)
ユーザー tentententen
提出日時 2023-03-03 12:46:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 430 ms / 5,000 ms
コード長 1,837 bytes
コンパイル時間 2,601 ms
コンパイル使用メモリ 85,548 KB
実行使用メモリ 56,788 KB
最終ジャッジ日時 2023-10-18 00:57:17
合計ジャッジ時間 9,703 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
54,504 KB
testcase_01 AC 82 ms
54,364 KB
testcase_02 AC 164 ms
55,948 KB
testcase_03 AC 81 ms
54,360 KB
testcase_04 AC 81 ms
54,440 KB
testcase_05 AC 81 ms
54,508 KB
testcase_06 AC 84 ms
54,388 KB
testcase_07 AC 108 ms
56,084 KB
testcase_08 AC 137 ms
56,092 KB
testcase_09 AC 107 ms
56,196 KB
testcase_10 AC 118 ms
56,072 KB
testcase_11 AC 118 ms
56,092 KB
testcase_12 AC 119 ms
53,864 KB
testcase_13 AC 122 ms
55,904 KB
testcase_14 AC 254 ms
55,904 KB
testcase_15 AC 134 ms
56,096 KB
testcase_16 AC 124 ms
55,916 KB
testcase_17 AC 354 ms
55,908 KB
testcase_18 AC 274 ms
56,060 KB
testcase_19 AC 132 ms
56,020 KB
testcase_20 AC 114 ms
55,932 KB
testcase_21 AC 114 ms
56,052 KB
testcase_22 AC 430 ms
55,912 KB
testcase_23 AC 125 ms
55,912 KB
testcase_24 AC 115 ms
55,908 KB
testcase_25 AC 163 ms
56,032 KB
testcase_26 AC 122 ms
56,028 KB
testcase_27 AC 133 ms
56,216 KB
testcase_28 AC 118 ms
55,936 KB
testcase_29 AC 113 ms
55,900 KB
testcase_30 AC 125 ms
56,788 KB
testcase_31 AC 128 ms
56,064 KB
testcase_32 AC 114 ms
56,172 KB
testcase_33 AC 126 ms
55,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long n = sc.nextLong();
        long min = n - 1;
        for (int i = 1; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                for (int j = i; j <= Math.sqrt(n / i); j++) {
                    if (n / i % j == 0) {
                        min = Math.min(min, i + j + n / i / j - 3);
                    }
                }
            }
        }
        System.out.println(min + " " + (n - 1));
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0