; ハッシュ表に予約された部屋番号と予約数のペアを書いていく ; ハッシュ表内を走査し予約数が2以上であれば都度(p1+p2)*(予約数-1)を足していく (defun main (&rest argv) (declare (ignorable argv)) (let* ((p1 (read)) (p2 (read)) (p (+ p1 p2)) (n (read)) ; https://cl-community-spec.github.io/pages/make_002dhash_002dtable.html ; make-hash-table &key test size rehash-size rehash-threshold ⇒ hash-table (tabl (make-hash-table))) (dotimes (_ n) ; https://cl-community-spec.github.io/pages/gethash.html ; gethash key hash-table &optional default ⇒ value, present-p (incf (gethash (read) tabl 0))) ; https://cl-community-spec.github.io/pages/loop.html ; for-as-hash ::= var [type-spec] being {each | the} {{hash-key | hash-keys} {in | of} hash-table [using (hash-value other-var)] | {hash-value | hash-values} {in | of} hash-table [using (hash-key other-var)]} (princ (loop for value being each hash-values of tabl sum (* (1- value) p))) (terpri))) (main)