結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー ryubokuryuboku
提出日時 2017-06-23 23:07:10
言語 Java
(openjdk 23)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 1,872 ms
コンパイル使用メモリ 74,732 KB
実行使用メモリ 54,328 KB
最終ジャッジ日時 2024-10-03 03:32:22
合計ジャッジ時間 6,342 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main{
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        if (k == 0 || k > n) {
            System.out.println(0);
        } else if (n % 2 == 1 && k == (n + 1) / 2) {
            System.out.println(n - 1);
        } else {
            System.out.println(n - 2);
        }
    }    
}
0