結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー KitataiKitatai
提出日時 2023-05-28 15:44:17
言語 Common Lisp
(sbcl 2.3.8)
結果
RE  
実行時間 -
コード長 501 bytes
コンパイル時間 1,096 ms
コンパイル使用メモリ 34,836 KB
実行使用メモリ 133,340 KB
最終ジャッジ日時 2023-08-27 12:50:02
合計ジャッジ時間 8,029 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 TLE -
testcase_03 RE -
testcase_04 RE -
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 27 AUG 2023 12:49:54 PM):
; processing (DEFUN FACD ...)
; processing (DEFUN FACTORIAL ...)
; processing (DEFUN RUI ...)
; processing (DEFUN SOLVE ...)
; 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 WARNING condition


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

ソースコード

diff #

(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 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 (* (facd (+ n 1) p 1) (rui f f)) 1000000007) 
)

(princ (solve (read) (read)))
0