結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー tanson
提出日時 2025-10-14 00:40:14
言語 Standard ML
(MLton 20210117)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 400 bytes
コンパイル時間 3,859 ms
コンパイル使用メモリ 687,352 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-14 00:40:20
合計ジャッジ時間 5,312 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

fun readInt () =
    valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn)


val () =
    let
        val n = readInt ()
        val k = readInt ()

        val ans = if k = 0 orelse k > n then 0
                  else if n = 1 then 0
                  else if n mod 2 = 1 andalso n - k = k - 1 then n - 1
                  else n - 2
    in
        print (Int.toString ans ^ "\n")
    end
0