結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー AOW_MIRROR_O5AOW_MIRROR_O5
提出日時 2018-03-08 17:39:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 4,120 ms
コンパイル使用メモリ 74,644 KB
実行使用メモリ 41,948 KB
最終ジャッジ日時 2024-04-15 12:16:14
合計ジャッジ時間 9,647 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
41,376 KB
testcase_01 AC 154 ms
41,488 KB
testcase_02 AC 154 ms
41,356 KB
testcase_03 AC 158 ms
41,440 KB
testcase_04 AC 165 ms
41,312 KB
testcase_05 AC 156 ms
41,192 KB
testcase_06 AC 166 ms
41,252 KB
testcase_07 AC 163 ms
41,536 KB
testcase_08 AC 162 ms
41,164 KB
testcase_09 AC 157 ms
41,688 KB
testcase_10 AC 155 ms
41,004 KB
testcase_11 AC 153 ms
41,312 KB
testcase_12 AC 151 ms
41,676 KB
testcase_13 AC 149 ms
41,128 KB
testcase_14 AC 155 ms
41,380 KB
testcase_15 AC 157 ms
41,196 KB
testcase_16 AC 160 ms
41,408 KB
testcase_17 AC 156 ms
41,256 KB
testcase_18 AC 163 ms
41,320 KB
testcase_19 AC 158 ms
41,372 KB
testcase_20 AC 156 ms
41,228 KB
testcase_21 AC 158 ms
41,628 KB
testcase_22 AC 159 ms
41,192 KB
testcase_23 AC 162 ms
41,372 KB
testcase_24 AC 155 ms
41,948 KB
testcase_25 AC 167 ms
41,492 KB
testcase_26 AC 162 ms
41,648 KB
testcase_27 AC 161 ms
41,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class paiza7 {
    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);
		}else if(N%2 == 0){
			System.out.println(N-2);
		}else{
			if((1+N)/2==K){
				System.out.println(N-1);
			}else{
				System.out.println(N-2);
			}
    	}
    }
}
0