結果
問題 | No.1747 Many Formulae 2 |
ユーザー | motoshira |
提出日時 | 2021-11-19 21:36:56 |
言語 | Common Lisp (sbcl 2.3.8) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 3,789 bytes |
コンパイル時間 | 981 ms |
コンパイル使用メモリ | 36,636 KB |
実行使用メモリ | 27,032 KB |
最終ジャッジ日時 | 2023-08-30 07:40:14 |
合計ジャッジ時間 | 1,985 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9 ms
22,956 KB |
testcase_01 | AC | 9 ms
22,976 KB |
testcase_02 | AC | 9 ms
22,888 KB |
testcase_03 | AC | 9 ms
22,900 KB |
testcase_04 | AC | 9 ms
22,916 KB |
testcase_05 | AC | 11 ms
26,940 KB |
testcase_06 | AC | 9 ms
22,884 KB |
testcase_07 | AC | 9 ms
22,952 KB |
testcase_08 | AC | 10 ms
27,012 KB |
testcase_09 | AC | 9 ms
23,000 KB |
testcase_10 | AC | 10 ms
26,952 KB |
testcase_11 | AC | 10 ms
27,032 KB |
testcase_12 | AC | 10 ms
22,992 KB |
testcase_13 | AC | 9 ms
23,016 KB |
testcase_14 | AC | 10 ms
26,996 KB |
testcase_15 | AC | 11 ms
24,936 KB |
testcase_16 | AC | 10 ms
22,956 KB |
testcase_17 | AC | 9 ms
25,044 KB |
testcase_18 | AC | 9 ms
22,952 KB |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 30 AUG 2023 07:40:12 AM): ; processing (IN-PACKAGE #:CL-USER) ; processing (DECLAIM (OPTIMIZE # ...)) ; processing (DECLAIM (MUFFLE-CONDITIONS COMPILER-NOTE)) ; processing (DISABLE-DEBUGGER) ; processing (PUSHNEW :INLINE-GENERIC-FUNCION ...) ; processing (IN-PACKAGE #:CL-USER) ; processing (DECLAIM (INLINE PRIME-FACTORIZE-TO-LIST)) ; processing (DEFUN PRIME-FACTORIZE-TO-LIST ...) ; processing (DECLAIM (INLINE PRIME-P)) ; processing (DEFUN PRIME-P ...) ; processing (DEFUN ENUMERATE-DIVISOR ...) ; processing (DECLAIM (INLINE PRINTLN)) ; processing (DEFUN PRINTLN ...) ; processing (DEFUN READ-INTO ...) ; processing (DEFUN MAIN ...) ; processing (MAIN) ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.083
ソースコード
(in-package #:cl-user) ;;------------------------------Preferences------------------------------ (eval-when (:compile-toplevel :load-toplevel :execute) #+swank (declaim (optimize (speed 3) (safety 2))) #-swank (declaim (optimize (speed 3) (safety 0) (debug 0))) #+swank (load "~/ghq/github.com/motoshira/atcoder-submission/ac-tools/act.lisp") #+swank (ql:quickload :prove) #-swank (declaim (sb-ext:muffle-conditions sb-ext:compiler-note)) #-swank (sb-ext:disable-debugger) (pushnew :inline-generic-funcion *features*)) ;;---------------------------------Body--------------------------------- (in-package #:cl-user) ;; Functions for prime (declaim (inline prime-factorize-to-list)) (defun prime-factorize-to-list (integer) ;; 素因数分解分解してリストで返す(昇順) (declare ((integer 0) integer)) (the list (if (<= integer 1) nil (loop while (<= (* f f) integer) with acc list = nil with f integer = 2 do (if (zerop (rem integer f)) (progn (push f acc) (setq integer (floor integer f))) (incf f)) finally (when (/= integer 1) (push integer acc)) (return (reverse acc)))))) (declaim (inline prime-p)) (defun prime-p (integer) (declare ((integer 1) integer)) (if (= integer 1) nil (loop with f = 2 while (<= (* f f) integer) do (when (zerop (rem integer f)) (return nil)) (incf f) finally (return t)))) (defun enumerate-divisor (k) (if (= k 1) (list 1) (labels ((sub (k d acc) (cond ((> (* d d) k) (sort acc #'<)) ((zerop (rem k d)) (sub k (1+ d) (if (= (* d d) k) (cons d acc) (cons d (cons (floor k d) acc))))) (t (sub k (1+ d) acc))))) (sub k 1 nil)))) (declaim (inline println)) (defun println (obj &optional (stream *standard-output*)) (let ((*read-default-float-format* 'double-float)) (prog1 obj (princ obj stream) (terpri stream)))) (defun read-into (count &optional (result-type 'list) (reader #'read)) (coerce (loop :repeat count :collect (funcall reader)) result-type)) (defun main () (let ((xs (map 'list #'digit-char-p (read-line)))) (println (sb-int:named-let rec ((xs xs) (tmp 0) (acc 0)) (if (null xs) (if (prime-p (+ acc tmp)) 1 0) (+ (if (or (plusp tmp) (plusp acc)) (rec (rest xs) (first xs) (+ tmp acc)) 0) (rec (rest xs) (+ (* tmp 10) (first xs)) acc))))))) #-swank (main) #+swank (defun run () (let ((*standard-input* (make-string-input-stream (with-output-to-string (*standard-output*) (run-program (merge-pathnames "copy-or-paste" (truename "~/bin/")) '() :output *standard-output*))))) (main)))