結果

問題 No.375 立方体のN等分 (1)
ユーザー tentententen
提出日時 2021-12-02 10:33:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 538 ms / 5,000 ms
コード長 1,280 bytes
コンパイル時間 2,275 ms
コンパイル使用メモリ 74,564 KB
実行使用メモリ 54,292 KB
最終ジャッジ日時 2023-09-18 10:11:50
合計ジャッジ時間 8,305 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
52,464 KB
testcase_01 AC 73 ms
52,408 KB
testcase_02 AC 164 ms
54,048 KB
testcase_03 AC 74 ms
52,364 KB
testcase_04 AC 72 ms
50,916 KB
testcase_05 AC 81 ms
52,384 KB
testcase_06 AC 76 ms
52,248 KB
testcase_07 AC 92 ms
53,760 KB
testcase_08 AC 139 ms
53,788 KB
testcase_09 AC 95 ms
53,856 KB
testcase_10 AC 106 ms
54,292 KB
testcase_11 AC 104 ms
53,976 KB
testcase_12 AC 109 ms
54,228 KB
testcase_13 AC 108 ms
54,192 KB
testcase_14 AC 272 ms
53,848 KB
testcase_15 AC 119 ms
53,712 KB
testcase_16 AC 109 ms
53,996 KB
testcase_17 AC 424 ms
53,744 KB
testcase_18 AC 294 ms
53,780 KB
testcase_19 AC 118 ms
54,088 KB
testcase_20 AC 104 ms
53,916 KB
testcase_21 AC 100 ms
54,032 KB
testcase_22 AC 538 ms
54,152 KB
testcase_23 AC 110 ms
54,008 KB
testcase_24 AC 100 ms
53,792 KB
testcase_25 AC 155 ms
54,000 KB
testcase_26 AC 111 ms
53,948 KB
testcase_27 AC 119 ms
53,964 KB
testcase_28 AC 110 ms
53,896 KB
testcase_29 AC 102 ms
53,704 KB
testcase_30 AC 112 ms
53,936 KB
testcase_31 AC 115 ms
53,908 KB
testcase_32 AC 101 ms
53,912 KB
testcase_33 AC 113 ms
53,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long n = sc.nextLong();
        long min = n - 1;
        for (long i = 1; i <= Math.sqrt(n); i++) {
            if (n % i != 0) {
                continue;
            }
            for (int j = 1; 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 Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    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 String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0