結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー KitataiKitatai
提出日時 2023-05-28 15:59:07
言語 Common Lisp
(sbcl 2.3.8)
結果
RE  
実行時間 -
コード長 590 bytes
コンパイル時間 1,149 ms
コンパイル使用メモリ 35,780 KB
実行使用メモリ 29,028 KB
最終ジャッジ日時 2023-08-27 13:32:09
合計ジャッジ時間 1,306 ms
ジャッジサーバーID
(参考情報)
judge12 / 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 AC 8 ms
22,660 KB
testcase_21 AC 8 ms
22,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 27 AUG 2023 01:32:06 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 FI (FACTORIAL N))
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::FI
; 
; compilation unit finished
;   Undefined variable:
;     FI
;   caught 1 WARNING condition


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

ソースコード

diff #

(defun facd (n p)
    (prog (pp count)
        (setq pp p)
        (setq count 0)
        loop
        (if (> pp n) (return count)
            (setq count (mod (+ count (/ (- n (mod n pp)) pp)) 1000000007))
        )
        (setq pp (* pp 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 fi (factorial n))
    (mod (* (facd n p) (rui fi fi)) 1000000007) 
)

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