結果
| 問題 |
No.721 Die tertia (ディエ・テルツィア)
|
| コンテスト | |
| ユーザー |
Common Lisp
|
| 提出日時 | 2024-10-18 02:41:40 |
| 言語 | Common Lisp (sbcl 2.5.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 808 bytes |
| コンパイル時間 | 387 ms |
| コンパイル使用メモリ | 37,172 KB |
| 実行使用メモリ | 29,888 KB |
| 最終ジャッジ日時 | 2024-10-18 02:41:42 |
| 合計ジャッジ時間 | 1,555 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 18 OCT 2024 02:41:40 AM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.063
ソースコード
(defun leap-year-p (y)
(cond
((zerop (mod y 400)) t)
((zerop (mod y 100)) nil)
((zerop (mod y 4)) t)
(t nil)))
(defun days (y m)
(case m
(1 31)
(2 (if (leap-year-p y) 29 28))
(3 31)
(4 30)
(5 31)
(6 30)
(7 31)
(8 31)
(9 30)
(10 31)
(11 30)
(12 31)
(otherwise 31)))
(defun normalize (y m d)
(let ((ld (days y m)))
(cond ((= m 13) `(,(1+ y) 1 ,d))
((< ld d) (normalize y (1+ m) (- d ld)))
(t `(,y ,m ,d)))))
(defun main ()
(let* ((s (read-line))
(y (read-from-string s t nil :end 4))
(m (read-from-string s t nil :start 5 :end 7))
(d (+ 2 (read-from-string s t nil :start 8)))
(x (normalize y m d)))
(format t "~4,'0d/~2,'0d/~2,'0d~%" (nth 0 x) (nth 1 x) (nth 2 x))))
(main)
Common Lisp