結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー 37zigen
提出日時 2020-02-18 15:38:12
言語 Java
(openjdk 23)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 2,211 ms
コンパイル使用メモリ 75,008 KB
実行使用メモリ 41,456 KB
最終ジャッジ日時 2024-10-06 15:35:10
合計ジャッジ時間 5,842 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		if(K==0||K>N) {
			System.out.println(0);
			return;
		}
		System.out.println(K==N-K+1?N-1:N-2);
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}
0