結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー samplelpmas
提出日時 2017-06-05 11:26:25
言語 Java
(openjdk 23)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 1,947 ms
コンパイル使用メモリ 74,860 KB
実行使用メモリ 54,236 KB
最終ジャッジ日時 2024-09-22 06:47:27
合計ジャッジ時間 6,405 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        if (K == 0 || K > N) {
            System.out.println(0);
            return;
        }

        if (N % 2 == 1 && K == (N + 1) / 2) {
            System.out.println(N - 1);
        } else {
            System.out.println(N - 2);
        }

    }

}
0