結果

問題 No.376 立方体のN等分 (2)
ユーザー htensaihtensai
提出日時 2020-02-07 08:32:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,019 ms / 5,000 ms
コード長 1,098 bytes
コンパイル時間 3,338 ms
コンパイル使用メモリ 82,828 KB
実行使用メモリ 58,668 KB
最終ジャッジ日時 2023-10-25 22:59:48
合計ジャッジ時間 19,813 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
54,184 KB
testcase_01 AC 75 ms
54,268 KB
testcase_02 AC 201 ms
56,312 KB
testcase_03 AC 219 ms
56,684 KB
testcase_04 AC 214 ms
56,744 KB
testcase_05 AC 75 ms
54,260 KB
testcase_06 AC 88 ms
55,808 KB
testcase_07 AC 81 ms
55,848 KB
testcase_08 AC 102 ms
55,876 KB
testcase_09 AC 126 ms
56,292 KB
testcase_10 AC 318 ms
58,592 KB
testcase_11 AC 148 ms
55,904 KB
testcase_12 AC 173 ms
56,760 KB
testcase_13 AC 173 ms
56,764 KB
testcase_14 AC 174 ms
55,948 KB
testcase_15 AC 185 ms
55,884 KB
testcase_16 AC 1,687 ms
58,588 KB
testcase_17 AC 200 ms
56,644 KB
testcase_18 AC 200 ms
55,864 KB
testcase_19 AC 211 ms
55,980 KB
testcase_20 AC 203 ms
55,880 KB
testcase_21 AC 1,766 ms
58,568 KB
testcase_22 AC 211 ms
56,768 KB
testcase_23 AC 1,824 ms
58,668 KB
testcase_24 AC 1,710 ms
56,552 KB
testcase_25 AC 208 ms
55,884 KB
testcase_26 AC 2,019 ms
58,588 KB
testcase_27 AC 211 ms
55,880 KB
testcase_28 AC 212 ms
55,880 KB
testcase_29 AC 213 ms
55,864 KB
testcase_30 AC 216 ms
56,672 KB
testcase_31 AC 221 ms
56,768 KB
testcase_32 AC 218 ms
56,768 KB
testcase_33 AC 213 ms
55,908 KB
testcase_34 AC 219 ms
55,896 KB
testcase_35 AC 212 ms
55,876 KB
testcase_36 AC 213 ms
56,084 KB
testcase_37 AC 212 ms
56,008 KB
testcase_38 AC 219 ms
55,884 KB
testcase_39 AC 216 ms
55,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n = Long.parseLong(br.readLine());
        TreeSet<Long> set = new TreeSet<>();
        for (long i = 1; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                set.add(i);
                set.add(n / i);
            }
        }
        long min = Long.MAX_VALUE;
        for (long x : set) {
            if (x > Math.sqrt(n)) {
                break;
            }
            for (long y : set) {
                if (y > Math.sqrt(n)) {
                    break;
                }
                if (x * y > n) {
                    break;
                }
                if (x > y) {
                    continue;
                }
                if ((n / x) % y != 0) {
                    continue;
                }
                min = Math.min(min, x + y + n / x / y - 3);
            }
        }
        System.out.println(min + " " + (n - 1));
   }
}
0