結果

問題 No.822 Bitwise AND
ユーザー keiden
提出日時 2024-09-22 19:31:29
言語 Scheme
(Gauche-0.9.15)
結果
AC  
実行時間 870 ms / 2,000 ms
コード長 510 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 23,168 KB
最終ジャッジ日時 2024-09-22 19:31:36
合計ジャッジ時間 4,243 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

(use scheme.bitwise)

(define yuki812
  (let* ((n (read)) (k (read)))
    (if (> k n)
      (display "INF\n")
      (let loop-x ((x n) (res 0))
        (if (> x (* 2 n))
          (print res)
          (if (= (bitwise-and n x) n)
            (let loop-y ((y x) (res res))
              (if (> y (+ x k))
                (loop-x (+ x 1) res)
                (if (= (bitwise-and x y) n)
                  (loop-y (+ y 1) (+ res 1))
                  (loop-y (+ y 1) res))))
            (loop-x (+ x 1) res)))))))
0