Let's write β

プログラミング中にできたことか、思ったこととか

2012-07-06から1日間の記事一覧

ICPC2005 ProblemA

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…

ICPC2004 Problem A

Hanafuda Shuffle もちろんLispで (defun create-deck (num) (loop for card from num downto 1 collect card)) (defun cut (cards p c) (let ((head (loop for idx from 1 upto (1- p) collect (nth (1- idx) cards))) (selected (loop for idx from p upto…

ICPC2012 Problem B

さて、ひきつづき、問題Bです。 こちらも、乱暴な事ができるLispの出番です。 (defun convert-to-zero-filled-str (num len) (format nil "~v,'0,,D" len num)) (defun next-num (num len) (let* ((num-str (convert-to-zero-filled-str num len)) (max-num …

ICPC2012 Problem A

ICPC2012の問題が公開になりました。 http://www.psg.cs.titech.ac.jp/icpc/icpc2012/contest/all_ja.html というわけでLispで解いてみましょう。 さて、ProblemAですが、こんな感じですかね。 (defun calc-year-day (year) (if (zerop (mod year 3)) (* 20 …

ICPC2005 ProblemA

Keitai Message これもまぁ素直な実装ね。再帰でやるのがたのしい (defvar *button-table* '((#\. #\, #\! #\? #\Space) (#\a #\b #\c) (#\d #\e #\f) (#\g #\h #\i) (#\j #\k #\l) (#\m #\m #\o) (#\p #\q #\r #\s) (#\t #\u #\v) (#\w #\x #\y #\z))) (def…