結果

問題 No.477 MVP
ユーザー tentententen
提出日時 2022-09-13 10:29:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 50 ms / 1,000 ms
コード長 1,262 bytes
コンパイル時間 4,338 ms
コンパイル使用メモリ 74,212 KB
実行使用メモリ 51,388 KB
最終ジャッジ日時 2023-08-20 11:57:53
合計ジャッジ時間 3,521 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
49,528 KB
testcase_01 AC 49 ms
49,292 KB
testcase_02 AC 49 ms
49,376 KB
testcase_03 AC 50 ms
49,248 KB
testcase_04 AC 49 ms
49,380 KB
testcase_05 AC 48 ms
49,428 KB
testcase_06 AC 50 ms
49,392 KB
testcase_07 AC 50 ms
51,388 KB
testcase_08 AC 50 ms
49,596 KB
testcase_09 AC 49 ms
49,312 KB
testcase_10 AC 49 ms
49,876 KB
testcase_11 AC 48 ms
47,504 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 k = sc.nextLong();
        long left = 0;
        long right = n;
        while (right - left > 1) {
            long m = (left + right) / 2;
            if ((n - m) / m < k) {
                right = m;
            } else {
                left = m;
            }
        }
        System.out.println(right);
    }
}
    
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    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 {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0