結果

問題 No.1237 EXP Multiple!
ユーザー motoshiramotoshira
提出日時 2020-10-14 22:26:39
言語 Common Lisp
(sbcl 2.3.8)
結果
AC  
実行時間 238 ms / 2,000 ms
コード長 776 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 33,680 KB
実行使用メモリ 31,676 KB
最終ジャッジ日時 2023-09-28 00:59:30
合計ジャッジ時間 3,309 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
23,012 KB
testcase_01 AC 158 ms
27,896 KB
testcase_02 AC 210 ms
27,980 KB
testcase_03 AC 213 ms
31,676 KB
testcase_04 AC 238 ms
27,968 KB
testcase_05 AC 76 ms
29,916 KB
testcase_06 AC 77 ms
27,892 KB
testcase_07 AC 73 ms
27,996 KB
testcase_08 AC 82 ms
27,884 KB
testcase_09 AC 72 ms
27,992 KB
testcase_10 AC 73 ms
30,040 KB
testcase_11 AC 77 ms
31,556 KB
testcase_12 AC 76 ms
31,572 KB
testcase_13 AC 82 ms
27,908 KB
testcase_14 AC 82 ms
31,536 KB
testcase_15 AC 81 ms
27,968 KB
testcase_16 AC 81 ms
29,920 KB
testcase_17 AC 81 ms
27,912 KB
testcase_18 AC 81 ms
27,936 KB
testcase_19 AC 75 ms
29,972 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 28 SEP 2023 12:59:26 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.008

ソースコード

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