結果

問題 No.2793 Mancala Master
ユーザー Lisp_CoderLisp_Coder
提出日時 2024-06-22 17:41:45
言語 Common Lisp
(sbcl 2.3.8)
結果
AC  
実行時間 781 ms / 2,000 ms
コード長 978 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 29,696 KB
実行使用メモリ 27,392 KB
最終ジャッジ日時 2024-06-25 10:45:23
合計ジャッジ時間 6,498 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
22,528 KB
testcase_01 AC 9 ms
22,656 KB
testcase_02 AC 53 ms
23,040 KB
testcase_03 AC 258 ms
24,704 KB
testcase_04 AC 94 ms
23,296 KB
testcase_05 AC 111 ms
23,424 KB
testcase_06 AC 307 ms
25,088 KB
testcase_07 AC 114 ms
23,424 KB
testcase_08 AC 187 ms
24,064 KB
testcase_09 AC 205 ms
24,320 KB
testcase_10 AC 15 ms
22,528 KB
testcase_11 AC 552 ms
26,240 KB
testcase_12 AC 86 ms
23,296 KB
testcase_13 AC 616 ms
26,624 KB
testcase_14 AC 254 ms
24,192 KB
testcase_15 AC 207 ms
23,936 KB
testcase_16 AC 529 ms
27,392 KB
testcase_17 AC 527 ms
27,264 KB
testcase_18 AC 781 ms
27,264 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 25 JUN 2024 10:45:16 AM):

; file: /home/judge/data/code/Main.lisp
; in: DEFUN MODINT998
;     (MOD CODEFORCES::X 998244353)
; 
; note: unable to
;   optimize
; due to type uncertainty:
;   The first argument is a REAL, not a SINGLE-FLOAT.
; 
; note: unable to
;   optimize
; due to type uncertainty:
;   The first argument is a REAL, not a DOUBLE-FLOAT.
; 
; note: unable to
;   optimize
; due to type uncertainty:
;   The first argument is a REAL, not a INTEGER.
; 
; note: unable to
;   convert division by 2^k to shift
; due to type uncertainty:
;   The first argument is a REAL, not a INTEGER.

; in: DEFUN MINT-POW
;     (> CODEFORCES::N 0)
; 
; note: unable to
;   open-code FLOAT to RATIONAL comparison
; due to type uncertainty:
;   The first argument is a REAL, not a SINGLE-FLOAT.
; 
; note: unable to
;   open-code FLOAT to RATIONAL comparison
; due to type uncertainty:
;   The first argument is a REAL, not a DOUBLE-FLOAT.
; 
; note: forced to do GENERIC-> (cost 10)
;       unable to do inline fixnum comparison (cost 3) because:
;       The first argument is a REAL, not a FIXNUM.
;       unable to do inline fixnum comparison (cost 4) because:
;       The first argument is a REAL, not a FIXNUM.
;       etc.

;     (* CODEFORCES::RESULT CODEFORCES::BASE)
; 
; note: forced to do GENERIC-* (cost 30)
;       unable to do inline fixnum arithmetic (cost 2) because:
;       The first argument is a (OR FLOAT (RATIONAL 0 (998244353))), not a FIXNUM.
;       The second argument is a (OR FLOAT (RATIONAL 0 (998244353))), not a FIXNUM.
;       The result is a (VALUES (OR FLOAT (RATIONAL 0 (996491788296388609)))
;                               &OPTIONAL), not a (VALUES FIXNUM &OPTIONAL).
;       unable to do inline (signed-byte 64) arithmetic (cost 4) because:
;       The first argument is a (OR FLOAT (RATIONAL 0 (998244353))), not a (SIGNED-BYTE
;                                                                           

ソースコード

diff #

(defpackage :codeforces
  (:use :cl :sb-int))
(in-package :codeforces)

(declaim (optimize (speed 3) (safety 0)))

(defun modint998 (x)
  (mod x 998244353))

(defun mint-pow (x n)
  (let ((result 1)
        (base (modint998 x)))
    (loop while (> n 0) do
          (when (oddp n)
            (setf result (modint998 (* result base))))
          (setf base (modint998 (* base base)))
          (setf n (floor n 2)))
    result))

(defun solve (n k a)
  (let ((ans 1))
    (loop for i from 1 to n do
          (setf ans (modint998 (* ans (- (mint-pow k i) 1)))))
    (loop for i from 0 below n do
          (setf ans (modint998 (* ans (mint-pow k (* (+ i 1) (1- (aref a i))))))))
    (princ ans) (terpri)))

(defun main ()
  (let ((num-cases (read)))
    (loop for _ from 1 to num-cases do
          (let* ((n (read))
                 (k (read))
                 (a (make-array n :initial-contents (loop for _ from 1 to n collect (read)))))
            (solve n k a)))))

(main)
0