結果
問題 | No.29 パワーアップ |
ユーザー |
![]() |
提出日時 | 2024-10-06 17:02:17 |
言語 | Common Lisp (sbcl 2.5.0) |
結果 |
AC
|
実行時間 | 9 ms / 5,000 ms |
コード長 | 1,289 bytes |
コンパイル時間 | 1,051 ms |
コンパイル使用メモリ | 27,392 KB |
実行使用メモリ | 21,760 KB |
最終ジャッジ日時 | 2024-10-06 17:02:19 |
合計ジャッジ時間 | 939 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 06 OCT 2024 05:02:16 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.027
ソースコード
; 入力を全て受け取り0-9の配列にカウントしていく; 2で割れた回数とカウントが奇数の個数を足して4で割った数を足す(defun main ()(let* ((n (read)); 初期値 0, 要素数 10 の配列を作成する(xs (make-array 10 :initial-element 0))); 入力される数は 3 * n個(dotimes (_ (* 3 n)); incf n は setq n (1+ n) と同じ働きを持つ(incf; aref は配列へのアクセス(aref xs (1- (read)))))(let ((s (+; across キーワードは loop マクロの中で; 配列を走査するときに使う(loop for c across xs; ash x i; x を i ビット左へシフトする関数; i が負の数ならば右へ (abs i) ビットシフトするsum (ash c -1)); floor 関数は数値の切り捨てに使う関数だが; 割り算の結果を整数に切り捨てるときにも使われる(floor; count-if pred seq; pred を満たす seq 内の要素の個数を返す関数(count-if #'oddp xs) 4))))(princ s)(terpri))))(main)