LoginSignup
1
0

More than 5 years have passed since last update.

【もげぞうβ】atcoder beginner contest001をやる

Last updated at Posted at 2018-12-01

PeerCast プログラミング配信 Advent Calendar 2018 一日目

はい、もげぞうβです。
カレンダー1日目は、atcoder beginner contest001をやりました。

  • A問題
(defun abc001a ()
  (format t "~d~%" (- (read) (read))))
  • B問題
    いいのかコレ
(defun abc001b ()
  (let ((vv 0)
    (m (read)))
    (cond
      ((> 100 m)
       nil)
      ((>= 5000 m 100)
       (setf vv (* (/ m 1000) 10)))
      ((>= 30000 m 6000)
       (setf vv (+ (/ m 1000) 50)))
      ((>= 70000 m 35000)
       (setf vv (+ (/ (- (/ m 1000) 30) 5) 80)))
      ((> m 70000)
       (setf vv 89)))
    (format t "~2,'0d~%" vv)))
  • C問題
    うーん・・・(´・ω・`)
(defun hoge (x)
  (multiple-value-bind (a b)
      (floor (* 10 x) 1)
    (if (>= b 0.5)
    (incf a))
    (/ a 10.0)))

(defun abc001c ()
  (let ((x (/ (read) 10.0))
    (y (hoge (/ (read) 60.0)))
    (dir "N") (W 0))
    (cond
      ((and (> 33.75 x) (>= x 11.25))
       (setf dir "NNE"))
      ((and (>= x 33.75) (> 56.25 x))
       (setf dir "NE"))
      ((and (>= x 56.25) (> 78.75 x))
       (setf dir "ENE"))
      ((and (>= x 78.75) (> 101.25 x))
       (setf dir "E"))
      ((and (>= x 101.25) (> 123.75 x))
       (setf dir "ESE"))
      ((and (>= x 123.75) (> 146.25 x))
       (setf dir "SE"))
      ((and (>= x 146.25) (> 168.75 x))
       (setf dir "SSE"))
      ((and (>= x 168.75) (> 191.25 x))
       (setf dir "S"))
      ((and (>= x 191.25) (> 213.75 x))
       (setf dir "SSW"))
      ((and (>= x 213.75) (> 236.25 x))
       (setf dir "SW"))
      ((and (>= x 236.25) (> 258.75 x))
       (setf dir "WSW"))
      ((and (>= x 258.75) (> 281.25 x))
       (setf dir "W"))
      ((and (>= x 281.25) (> 303.75 x))
       (setf dir "WNW"))
      ((and (>= x 303.75) (> 326.25 x))
       (setf dir "NW"))
      ((and (>= x 326.25) (> 348.75 x))
       (setf dir "NNW"))
      (t (setf dir "N")))
    (cond
      ((>= 0.2 y 0)
       (setf W 0
         dir "C"))
      ((>= 1.5 y 0.3)
       (setf W 1))
      ((>= 3.3 y 1.6)
       (setf W 2))
      ((>= 5.4 y 3.4)
       (setf W 3))
      ((>= 7.9 y 5.5)
       (setf W 4))
      ((>= 10.7 y 8.0)
       (setf W 5))
      ((>= 13.8 y 10.8)
       (setf W 6))
      ((>= 17.1 y 13.9)
       (setf W 7))
      ((>= 20.7 y 17.2)
       (setf W 8))
      ((>= 24.4 y 20.8)
       (setf W 9))
      ((>= 28.4 y 24.5)
       (setf W 10))
      ((>= 32.6 y 28.5)
       (setf W 11))
      ((>= y 32.7)
       (setf W 12)))
    (format t "~a ~d~%" dir W)))
  • D問題 あとで!

とりあえず配信できてよかった。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0