結果
問題 | No.289 数字を全て足そう |
ユーザー |
![]() |
提出日時 | 2024-10-09 11:10:35 |
言語 | Common Lisp (sbcl 2.5.0) |
結果 |
AC
|
実行時間 | 10 ms / 1,000 ms |
コード長 | 915 bytes |
コンパイル時間 | 1,908 ms |
コンパイル使用メモリ | 25,088 KB |
実行使用メモリ | 21,760 KB |
最終ジャッジ日時 | 2024-10-09 11:10:39 |
合計ジャッジ時間 | 1,496 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 09 OCT 2024 11:10:35 AM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.012
ソースコード
; 10 進数で数値と認められる文字以外を除去したのち ; それらを全て足し合わせる (defun main () ; remove-if-not test sequence &key from-end start end count key ⇒ result-sequence ; sequence の中で test を満たすシーケンスを返す (let* ((s (remove-if-not ; digit-char-p char &optional radix ⇒ weight ; char が radix で指定された基数の数字か調べそれに値する重みを返す ; デフォルトでは radix は 10 #'digit-char-p (read-line))) ; reduce function sequence &key key from-end start end initial-value ⇒ result ; key が指定されると sequence の各要素にたいして key 関数が 1 度ずつ適用される (ans (reduce #'+ s :key #'digit-char-p))) (princ ans) (terpri))) (main)