結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-13 17:51:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 362 bytes
コンパイル時間 2,873 ms
コンパイル使用メモリ 71,572 KB
実行使用メモリ 56,292 KB
最終ジャッジ日時 2023-08-20 00:52:23
合計ジャッジ時間 7,196 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
56,148 KB
testcase_01 AC 123 ms
55,596 KB
testcase_02 AC 122 ms
55,856 KB
testcase_03 AC 123 ms
55,720 KB
testcase_04 AC 123 ms
56,152 KB
testcase_05 AC 123 ms
55,880 KB
testcase_06 AC 124 ms
55,888 KB
testcase_07 AC 123 ms
55,776 KB
testcase_08 AC 123 ms
55,996 KB
testcase_09 AC 123 ms
54,136 KB
testcase_10 AC 123 ms
55,636 KB
testcase_11 AC 123 ms
55,784 KB
testcase_12 AC 124 ms
55,460 KB
testcase_13 AC 122 ms
55,628 KB
testcase_14 AC 123 ms
55,804 KB
testcase_15 AC 122 ms
55,960 KB
testcase_16 AC 124 ms
56,084 KB
testcase_17 AC 123 ms
55,960 KB
testcase_18 AC 124 ms
56,044 KB
testcase_19 AC 122 ms
55,928 KB
testcase_20 AC 125 ms
55,852 KB
testcase_21 AC 123 ms
55,760 KB
testcase_22 AC 121 ms
55,980 KB
testcase_23 AC 121 ms
56,168 KB
testcase_24 AC 124 ms
55,928 KB
testcase_25 AC 122 ms
56,292 KB
testcase_26 AC 121 ms
53,816 KB
testcase_27 AC 122 ms
56,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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