結果

問題 No.1157 Many Quotients easy
ユーザー tentententen
提出日時 2020-08-17 18:16:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 347 bytes
コンパイル時間 2,598 ms
コンパイル使用メモリ 74,312 KB
実行使用メモリ 54,428 KB
最終ジャッジ日時 2024-04-19 18:59:53
合計ジャッジ時間 6,010 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
54,216 KB
testcase_01 AC 116 ms
54,132 KB
testcase_02 AC 107 ms
53,160 KB
testcase_03 AC 116 ms
54,176 KB
testcase_04 AC 105 ms
53,184 KB
testcase_05 AC 115 ms
53,892 KB
testcase_06 AC 107 ms
53,012 KB
testcase_07 AC 118 ms
54,028 KB
testcase_08 AC 123 ms
54,196 KB
testcase_09 AC 117 ms
54,200 KB
testcase_10 AC 106 ms
52,996 KB
testcase_11 AC 107 ms
53,092 KB
testcase_12 AC 115 ms
53,132 KB
testcase_13 AC 113 ms
53,992 KB
testcase_14 AC 118 ms
54,040 KB
testcase_15 AC 118 ms
54,340 KB
testcase_16 AC 118 ms
53,836 KB
testcase_17 AC 107 ms
52,848 KB
testcase_18 AC 116 ms
54,428 KB
testcase_19 AC 118 ms
54,056 KB
testcase_20 AC 120 ms
54,128 KB
testcase_21 AC 108 ms
54,268 KB
testcase_22 AC 121 ms
54,088 KB
testcase_23 AC 109 ms
52,972 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 idx = (long)Math.sqrt(n);
        if (n / idx > n / (idx + 1)) {
            idx++;
        }
        long prev = 0;
        System.out.println(idx + n / idx - 1);
    }
}
0