koguro #3258(2007/10/05 12:34 GMT) [ Scheme ] Rating4/4=1.00
無駄が多いですが、普通に解いてみました。 ところで、反時計回りだとサンプルの出力は以下のようになるべきでは? 0, 0 1, 0 0, 1 -1, 0 0, -1 1, 1 -1, 1 -1, -1 1, -1 2, 0 ※(1, -1)と(-1, -1)が逆のはず。 ちなみに1,000番目は -8, 16 です。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
(use srfi-1) (use srfi-42) (use math.const) (define (make-point-list n) (let ((a (ceiling->exact (/ (sqrt (* 2 n)) 2)))) (list-ec (: x (- a) (+ a 1)) (: y (- a) (+ a 1)) (make-rectangular x y)))) (define (sort-point-list lst) (define (%angle z) (let1 t (angle z) (if (< t 0) (+ (* 2 pi) t) t))) (sort lst (lambda (z1 z2) (let ((r1 (magnitude z1)) (r2 (magnitude z2))) (if (= r1 r2) (< (%angle z1) (%angle z2)) (< r1 r2)))))) (define (lattice-point-list n) (for-each (lambda (z) (format #t "~d, ~d~%" (inexact->exact (real-part z)) (inexact->exact (imag-part z)))) (take (sort-point-list (make-point-list n)) n))) ;; (lattice-point-list 1000)を実行すると答えが出ます
Rating4/4=1.00-0+
[ reply ]
koguro #3258() [ Scheme ] Rating4/4=1.00
Rating4/4=1.00-0+
[ reply ]