結果

問題 No.1237 EXP Multiple!
ユーザー motoshiramotoshira
提出日時 2020-10-14 22:21:42
言語 Common Lisp
(sbcl 2.3.8)
結果
WA  
実行時間 -
コード長 772 bytes
コンパイル時間 759 ms
コンパイル使用メモリ 35,064 KB
実行使用メモリ 33,732 KB
最終ジャッジ日時 2023-09-28 00:59:26
合計ジャッジ時間 3,729 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
25,084 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 83 ms
29,952 KB
testcase_06 AC 85 ms
27,924 KB
testcase_07 AC 82 ms
29,952 KB
testcase_08 AC 90 ms
27,912 KB
testcase_09 AC 82 ms
27,956 KB
testcase_10 AC 83 ms
27,920 KB
testcase_11 AC 86 ms
33,724 KB
testcase_12 WA -
testcase_13 AC 90 ms
28,000 KB
testcase_14 AC 90 ms
27,916 KB
testcase_15 AC 90 ms
31,704 KB
testcase_16 AC 90 ms
31,616 KB
testcase_17 AC 89 ms
27,924 KB
testcase_18 AC 90 ms
27,964 KB
testcase_19 AC 84 ms
30,012 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 28 SEP 2023 12:59:21 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.187

ソースコード

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*) *mod*)
                   (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