結果

問題 No.376 立方体のN等分 (2)
ユーザー compass19compass19
提出日時 2016-06-06 12:53:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 561 ms / 5,000 ms
コード長 1,168 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 81,180 KB
実行使用メモリ 122,460 KB
最終ジャッジ日時 2024-04-24 13:50:43
合計ジャッジ時間 15,101 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
42,296 KB
testcase_01 AC 139 ms
42,244 KB
testcase_02 AC 288 ms
108,892 KB
testcase_03 AC 286 ms
106,272 KB
testcase_04 AC 307 ms
119,308 KB
testcase_05 AC 129 ms
42,120 KB
testcase_06 AC 146 ms
42,312 KB
testcase_07 AC 133 ms
42,428 KB
testcase_08 AC 138 ms
45,260 KB
testcase_09 AC 179 ms
59,604 KB
testcase_10 AC 211 ms
64,928 KB
testcase_11 AC 207 ms
78,052 KB
testcase_12 AC 230 ms
89,424 KB
testcase_13 AC 236 ms
91,464 KB
testcase_14 AC 248 ms
96,684 KB
testcase_15 AC 275 ms
102,732 KB
testcase_16 AC 508 ms
107,512 KB
testcase_17 AC 286 ms
109,360 KB
testcase_18 AC 275 ms
111,468 KB
testcase_19 AC 286 ms
113,532 KB
testcase_20 AC 281 ms
115,580 KB
testcase_21 AC 504 ms
115,880 KB
testcase_22 AC 303 ms
118,580 KB
testcase_23 AC 535 ms
119,752 KB
testcase_24 AC 524 ms
121,180 KB
testcase_25 AC 313 ms
120,660 KB
testcase_26 AC 561 ms
121,644 KB
testcase_27 AC 315 ms
121,972 KB
testcase_28 AC 290 ms
122,256 KB
testcase_29 AC 292 ms
122,240 KB
testcase_30 AC 312 ms
122,224 KB
testcase_31 AC 320 ms
122,380 KB
testcase_32 AC 312 ms
122,408 KB
testcase_33 AC 312 ms
122,424 KB
testcase_34 AC 296 ms
122,460 KB
testcase_35 AC 307 ms
121,980 KB
testcase_36 AC 297 ms
122,364 KB
testcase_37 AC 298 ms
121,936 KB
testcase_38 AC 301 ms
122,120 KB
testcase_39 AC 323 ms
122,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int l = (int)Math.floor(Math.sqrt(n));
        int cbrt = (int)Math.cbrt(n);
        long []y = new long [l];
        int tail = 0;
        for (long i = 1; i <= l; i++){
            if (n%i == 0)   y[tail++] = i;
        }
        long []x = new long [tail];
        for (int i = 0; i < tail; i++){
            x[i] = (long)(n/y[i]);
        }
        long m = -1;
        long a,b;
        for (int i = 0; i < tail; i++){
            if (y[i] <= cbrt){
                a = y[i];
                long sqrt = (long)Math.sqrt(n/a);
                for (int j = i; j < tail; j++){
                    b = y[j];
                    if (n%(a*b) == 0 && b <= sqrt){
                        if (m == -1){
                            m = a+b+(long)(n/(a*b))-3;
                        }else{
                            m = Math.min(a+b+(long)(n/(a*b))-3, m);
                        }
                    }
                }
            }
        }
        System.out.println(m+" "+(n-1));
    }
}
0