結果

問題 No.1237 EXP Multiple!
ユーザー motoshiramotoshira
提出日時 2020-10-14 22:18:49
言語 Common Lisp
(sbcl 2.3.8)
結果
WA  
実行時間 -
コード長 768 bytes
コンパイル時間 486 ms
コンパイル使用メモリ 29,656 KB
実行使用メモリ 31,672 KB
最終ジャッジ日時 2023-09-28 00:58:58
合計ジャッジ時間 3,207 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
23,036 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 78 ms
29,932 KB
testcase_06 WA -
testcase_07 AC 79 ms
27,964 KB
testcase_08 WA -
testcase_09 AC 80 ms
27,900 KB
testcase_10 AC 76 ms
27,884 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 82 ms
27,896 KB
testcase_14 AC 86 ms
31,560 KB
testcase_15 AC 82 ms
27,868 KB
testcase_16 AC 85 ms
27,992 KB
testcase_17 AC 83 ms
27,888 KB
testcase_18 AC 83 ms
29,948 KB
testcase_19 AC 76 ms
27,884 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 28 SEP 2023 12:58:53 AM):
; processing (DEFPARAMETER *MOD* ...)
; processing (DEFUN FACT ...)
; processing (DEFUN MAIN ...)
; processing (MAIN)

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

ソースコード

diff #

(defparameter *mod* 1000000007)

(defun fact (x)
  (if (zerop x)
      1
      (* x (fact (1- x)))))

(defun main ()
  (let ((n (read)))
    (let ((a (loop repeat n collect (read))))
      (labels ((sub (xs &optional (res 1))
                 (cond
                   ((null xs) (mod *mod* res))
                   ((> res *mod*) 0)
                   (t
                    (sub (rest xs) (* (expt (first xs)
                                            (fact (first xs)))
                                      res))))))
        (princ (if (some #'zerop a)
                   -1
                   (if (every (lambda (x)
                                (<= 1 x 3))
                              a)
                       (sub a)
                       0)))))))
(main)
0