結果

問題 No.2699 Simple Math (Returned)
ユーザー Lisp_CoderLisp_Coder
提出日時 2024-04-30 03:10:33
言語 Common Lisp
(sbcl 2.3.8)
結果
AC  
実行時間 1,165 ms / 2,000 ms
コード長 648 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 37,188 KB
実行使用メモリ 22,272 KB
最終ジャッジ日時 2024-04-30 03:10:47
合計ジャッジ時間 12,459 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
21,888 KB
testcase_01 AC 573 ms
22,016 KB
testcase_02 AC 990 ms
22,272 KB
testcase_03 AC 555 ms
22,272 KB
testcase_04 AC 1,165 ms
22,144 KB
testcase_05 AC 882 ms
22,016 KB
testcase_06 AC 804 ms
22,144 KB
testcase_07 AC 1,045 ms
22,144 KB
testcase_08 AC 1,046 ms
22,272 KB
testcase_09 AC 1,031 ms
22,144 KB
testcase_10 AC 1,050 ms
22,144 KB
testcase_11 AC 1,025 ms
22,144 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 30 APR 2024 03:10:33 AM):

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

ソースコード

diff #

(defparameter modint 998244353)

(defun modpow (x n)
  (let ((res 1))
    (loop
      (when (<= n 0) (return res))
      (when (oddp n)
        (setf res (mod (* res x) modint)))
      (setf x (mod (* x x) modint))
      (setf n (ash n -1)))))

(defun solve (n m)
  (setf n (mod n (* 2 m)))
  (if (<= n m)
      (format t "~d~%" (mod (1- (modpow 10 n)) modint))
    (let* ((a (modpow 10 m))
           (b (modpow 10 (- n m)))
           (ans (mod (- a b) modint)))
      (format t "~d~%" ans))))

(defun main ()
  (let ((num-tests (read)))
    (dotimes (i num-tests)
      (let* ((n (read))
             (m (read)))
        (solve n m)))))

(main)
0