結果
問題 | No.2326 Factorial to the Power of Factorial to the... |
ユーザー | Kitatai |
提出日時 | 2023-05-28 15:51:37 |
言語 | Common Lisp (sbcl 2.3.8) |
結果 |
RE
|
実行時間 | - |
コード長 | 751 bytes |
コンパイル時間 | 413 ms |
コンパイル使用メモリ | 34,116 KB |
実行使用メモリ | 31,996 KB |
最終ジャッジ日時 | 2023-08-27 13:08:37 |
合計ジャッジ時間 | 1,720 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 27 AUG 2023 01:08:35 PM): ; processing (DEFUN FACD ...) ; processing (DEFUN FACD2 ...) ; file: /home/judge/data/code/Main.lisp ; in: DEFUN FACD2 ; (PI COUNT) ; ; caught ERROR: ; COMMON-LISP:PI names a defined constant, and cannot be used in LET. ; (DEFUN FACD2 (N P) ; (PROG (PI COUNT) ; (SETQ PI P) ; (SETQ COUNT 0) ; LOOP ; (IF (> PI N) ; (RETURN COUNT) ; (SETQ COUNT #)) ; (SETQ PI (* PI P)) ; (GO LOOP))) ; --> PROGN SB-IMPL::%DEFUN SB-IMPL::%DEFUN SB-INT:NAMED-LAMBDA ; ==> ; #'(SB-INT:NAMED-LAMBDA FACD2 ; (N P) ; (DECLARE (SB-C::TOP-LEVEL-FORM)) ; (BLOCK FACD2 ; (PROG (PI COUNT) ; (SETQ PI P) ; (SETQ COUNT 0) ; LOOP ; (IF (> PI N) ; (RETURN COUNT) ; (SETQ #)) ; (SETQ PI #) ; (GO LOOP)))) ; ; caught STYLE-WARNING: ; The variable N is defined but never used. ; ; caught STYLE-WARNING: ; The variable P is defined but never used. ; processing (DEFUN FACTORIAL ...) ; processing (DEFUN RUI ...) ; processing (DEFUN SOLVE ...) ; file: /home/judge/data/code/Main.lisp ; in: DEFUN SOLVE ; (* (FACD2 N P) (RUI F F)) ; ; note: deleting unreachable code ; processing (PRINC (SOLVE # ...)) ; file: /home/judge/data/code/Main.lisp ; in: DEFUN SOLVE ; (SETQ F (FACTORIAL N)) ; ; caught WARNING: ; undefined variable: COMMON-LISP-USER::F ; ; compilation unit finished ; Undefined variable: ; F ; caught 1 ERROR condition ; caught 1 WARNING condition ; caught 2 STYLE-WARNING conditions ; printed 1 note ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.014
ソースコード
(defun facd (n p a) (cond ((equal n 0) 0) ((not (equal (mod a p) 0)) (facd (- n 1) p (* a (- n 1)))) (t (mod (+ (facd n p (/ a p)) 1) 1000000007)) ) ) (defun facd2 (n p) (prog (pi count) (setq pi p) (setq count 0) loop (if (> pi n) (return count) (setq count (mod (+ count (/ n pi)) 1000000007)) ) (setq pi (* pi p)) (go loop) ) ) (defun factorial (n) (if (= n 1) 1 (mod (* n (factorial (- n 1))) 1000000007) ) ) (defun rui (n p) (if (= n 1) p (mod (* p (rui (- n 1) p)) 1000000007) ) ) (defun solve (n p) (setq f (factorial n)) (mod (* (facd2 n p) (rui f f)) 1000000007) ) (princ (solve (read) (read)))