結果
| 問題 |
No.2699 Simple Math (Returned)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-30 03:10:33 |
| 言語 | Common Lisp (sbcl 2.5.0) |
| 結果 |
AC
|
| 実行時間 | 1,109 ms / 2,000 ms |
| コード長 | 648 bytes |
| コンパイル時間 | 300 ms |
| コンパイル使用メモリ | 28,160 KB |
| 実行使用メモリ | 22,272 KB |
| 最終ジャッジ日時 | 2024-11-19 15:06:39 |
| 合計ジャッジ時間 | 12,070 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 19 NOV 2024 03:06:26 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.026
ソースコード
(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)