結果
問題 | No.1140 EXPotentiaLLL! |
ユーザー | Common Lisp |
提出日時 | 2024-11-03 02:16:11 |
言語 | Common Lisp (sbcl 2.3.8) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,727 bytes |
コンパイル時間 | 244 ms |
コンパイル使用メモリ | 43,872 KB |
実行使用メモリ | 69,692 KB |
最終ジャッジ日時 | 2024-11-03 02:16:31 |
合計ジャッジ時間 | 20,155 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | TLE | - |
testcase_02 | TLE | - |
testcase_03 | AC | 1,459 ms
65,704 KB |
testcase_04 | AC | 1,156 ms
65,700 KB |
testcase_05 | AC | 1,715 ms
65,704 KB |
testcase_06 | AC | 1,673 ms
65,704 KB |
testcase_07 | AC | 1,975 ms
65,572 KB |
testcase_08 | AC | 173 ms
65,576 KB |
testcase_09 | AC | 199 ms
67,528 KB |
testcase_10 | AC | 169 ms
65,576 KB |
testcase_11 | AC | 172 ms
65,448 KB |
testcase_12 | AC | 171 ms
67,536 KB |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 03 NOV 2024 02:16:12 AM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.034
ソースコード
(defun sieve-of-atkin (lim) (let* ((slim (sqrt lim)) (p (make-array (+ lim 60) :initial-element 0))) (loop for v from 1 to (floor slim 2) do (let ((x (1+ (* 4 v v))) (y 8)) (loop while (<= x lim) do (when (not (= (mod x 12) 9)) (setf (aref p x) (logxor (aref p x) 1))) (setf x (+ x y) y (+ y 8))))) (loop for v from 1 to (floor (/ slim (sqrt 3))) by 2 do (let ((x (+ (* 3 v v) 4)) (y 12)) (loop while (<= x lim) do (when (= (mod x 12) 7) (setf (aref p x) (logxor (aref p x) 1))) (setf x (+ x y) y (+ y 8))))) (loop for v from 2 to (floor (/ slim (sqrt 2))) do (let ((x (1- (* 2 v (1+ v)))) (y (- (* 4 v) 8))) (loop while (and (<= x lim) (<= 0 y)) do (when (= (mod x 12) 11) (setf (aref p x) (logxor (aref p x) 1))) (setf x (+ x y) y (- y 8))))) (loop for n from 5 to (floor slim) do (when (/= (aref p n) 0) (loop for z from (* n n) below lim by (* n n) do (setf (aref p z) 0)))) (setf (aref p 2) 1 (aref p 3) 1) p)) (defun main (&rest argv) (declare (ignorable argv)) (let* ((q (read)) (p (sieve-of-atkin 5050505))) (dotimes (_ q) (let* ((a (read)) (s (read))) (if (zerop (aref p s)) (princ -1) (if (zerop (mod a s)) (princ 0) (princ 1))) (terpri))))) (main)