結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー tsunabit
提出日時 2019-06-13 01:48:21
言語 Java
(openjdk 23)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 429 bytes
コンパイル時間 3,865 ms
コンパイル使用メモリ 75,268 KB
実行使用メモリ 41,644 KB
最終ジャッジ日時 2024-10-12 06:36:59
合計ジャッジ時間 7,592 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;

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