結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー KitataiKitatai
提出日時 2023-05-28 15:10:11
言語 Common Lisp
(sbcl 2.3.8)
結果
WA  
実行時間 -
コード長 647 bytes
コンパイル時間 1,065 ms
コンパイル使用メモリ 27,392 KB
実行使用メモリ 21,760 KB
最終ジャッジ日時 2024-06-08 07:08:35
合計ジャッジ時間 2,106 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 08 JUN 2024 07:08:32 AM):

; file: /home/judge/data/code/Main.lisp
; in: DEFUN FACD
;     (MOD A P)
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::A

;     (* A N)
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::A

;     (SETQ A (* A N))
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::A

; 
; caught WARNING:
;   3 more uses of undefined variable A


; file: /home/judge/data/code/Main.lisp
; in: DEFUN SOLVE
;     (RUI F F)
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::F

;     (SETQ F (FACTORIAL N))
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::F
; 
; compilation unit finished
;   Undefined variables:
;     A F
;   caught 6 WARNING conditions

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

ソースコード

diff #

(defun facd (n p) 
    (if (= n 1) 0
        (prog (c)
            (setq a (* a n))
            (setq c 0)
            loop
            (if (not (equal (mod a p) 0)) (return (mod (+ (facd (- n 1) p) c) 1000000007)))
            (setq a (/ a p))
            (setq c (+ c 1))
            (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 a 1)
    (setq f (factorial n))
    (mod (* (facd n p) (rui f f)) 1000000007) 
)

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