結果

問題 No.375 立方体のN等分 (1)
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-17 01:56:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 360 ms / 5,000 ms
コード長 693 bytes
コンパイル時間 1,896 ms
コンパイル使用メモリ 73,908 KB
実行使用メモリ 57,328 KB
最終ジャッジ日時 2023-08-17 07:46:54
合計ジャッジ時間 9,188 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 146 ms
56,728 KB
testcase_01 AC 140 ms
56,692 KB
testcase_02 AC 191 ms
57,024 KB
testcase_03 AC 142 ms
56,744 KB
testcase_04 AC 136 ms
56,912 KB
testcase_05 AC 142 ms
56,936 KB
testcase_06 AC 141 ms
57,096 KB
testcase_07 AC 152 ms
56,432 KB
testcase_08 AC 173 ms
56,628 KB
testcase_09 AC 152 ms
56,752 KB
testcase_10 AC 160 ms
56,656 KB
testcase_11 AC 161 ms
57,004 KB
testcase_12 AC 164 ms
56,816 KB
testcase_13 AC 164 ms
56,792 KB
testcase_14 AC 247 ms
54,588 KB
testcase_15 AC 171 ms
56,756 KB
testcase_16 AC 166 ms
56,460 KB
testcase_17 AC 312 ms
56,800 KB
testcase_18 AC 260 ms
56,976 KB
testcase_19 AC 169 ms
56,924 KB
testcase_20 AC 158 ms
56,668 KB
testcase_21 AC 155 ms
56,952 KB
testcase_22 AC 360 ms
57,216 KB
testcase_23 AC 166 ms
57,044 KB
testcase_24 AC 158 ms
56,744 KB
testcase_25 AC 190 ms
56,824 KB
testcase_26 AC 166 ms
56,688 KB
testcase_27 AC 170 ms
56,828 KB
testcase_28 AC 157 ms
57,328 KB
testcase_29 AC 157 ms
57,244 KB
testcase_30 AC 163 ms
56,816 KB
testcase_31 AC 167 ms
56,568 KB
testcase_32 AC 153 ms
56,844 KB
testcase_33 AC 164 ms
56,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long M = (long)Math.cbrt(N);
        long Tmax = N-1;
        long Tmin = Tmax;
        for(long i=1; i<=M; i++){
            long a=N;
            if(a%i==0){
                long m = (long)Math.sqrt(a/i);
                for(long j=i; j<=m; j++){
                    long b = a/i;
                    if(b%j==0){
                        long c = b/j;
                        Tmin = Math.min(Tmin,i+j+c-3);
                    }
                }
            }
        }
        System.out.println(Tmin+" "+Tmax);
    }
}
0