Ohgas' Fortune
もちろんLis(ry
(defun fukuri (money year nenri tesuuryou) (if (zerop year) money (fukuri (- (+ money (floor (* money nenri))) tesuuryou) (1- year) nenri tesuuryou))) (defun tanri (money year nenri tesuuryou) (labels ((%tanri (money year nenri tesuuryou risi) (if (zerop year) (+ money risi) (%tanri (- money tesuuryou) (1- year) nenri tesuuryou (+ risi (floor (* money nenri))))))) (%tanri money year nenri tesuuryou 0))) (defun main () (let ((m (read))) (loop for i from 1 upto m for money = (read) then (read) for year = (read) then (read) for pattern = (read) then (read) do (format t "~A~%" (loop for j from 1 upto pattern maximize (if (zerop (read)) (tanri money year (read) (read)) (fukuri money year (read) (read))))))))
loopマクロ便利すぎわろりーぬ