結果

問題 No.2 素因数ゲーム
ユーザー Common Lisp
提出日時 2024-10-23 09:47:41
言語 Common Lisp
(sbcl 2.5.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 830 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 33,600 KB
実行使用メモリ 29,988 KB
最終ジャッジ日時 2024-10-23 09:47:43
合計ジャッジ時間 1,798 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 23 OCT 2024 09:47:41 AM):

; wrote /home/judge/data/code/Main.fasl
; compilation finished in 0:00:00.007

ソースコード

diff #

(defun factorize (n)
  (let ((p 3)
        (f '()))
    (let ((count 0))
      (loop while (and (> n 0) (zerop (mod n 2)))
            do (incf count)
               (setf n (/ n 2)))
      (push (cons 2 count) f))
    (loop while (<= (* p p) n)
          do (let ((count 0))
               (loop while (zerop (mod n p))
                     do (incf count)
                        (setf n (/ n p)))
               (when (> count 0)
                     (push (cons p count) f)))
            (incf p 2))
    (when (> n 1)
          (push (cons n 1) f))
    (nreverse f)))

(defun main (&rest argv)
  (declare (ignorable argv))
  (let* ((n (read)))
    (format t "~a~%" (if (zerop (reduce (lambda (x y) (logxor x (cdr y))) (factorize n) :initial-value 0))
                         "Bob"
                         "Alice"))))

(main)
0