結果

問題 No.883 ぬりえ
ユーザー MiyamonYMiyamonY
提出日時 2019-10-13 02:21:31
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 1,435 bytes
コンパイル時間 59 ms
コンパイル使用メモリ 5,304 KB
実行使用メモリ 15,536 KB
最終ジャッジ日時 2023-08-20 05:02:14
合計ジャッジ時間 2,980 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
11,760 KB
testcase_01 AC 19 ms
11,792 KB
testcase_02 AC 19 ms
11,784 KB
testcase_03 AC 19 ms
11,784 KB
testcase_04 AC 19 ms
11,820 KB
testcase_05 AC 20 ms
11,768 KB
testcase_06 AC 19 ms
11,820 KB
testcase_07 AC 19 ms
11,976 KB
testcase_08 AC 20 ms
11,748 KB
testcase_09 AC 19 ms
11,760 KB
testcase_10 AC 19 ms
11,752 KB
testcase_11 AC 19 ms
11,792 KB
testcase_12 AC 20 ms
11,832 KB
testcase_13 AC 19 ms
11,772 KB
testcase_14 AC 19 ms
11,964 KB
testcase_15 AC 148 ms
15,532 KB
testcase_16 AC 55 ms
15,536 KB
testcase_17 AC 33 ms
14,144 KB
testcase_18 AC 19 ms
11,832 KB
testcase_19 AC 19 ms
11,916 KB
testcase_20 AC 18 ms
11,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

;;; File:  main.scm
;; Author: ymiyamoto
;;
;; Created on Mon Oct  7 02:32:46 2019
;;
(define-syntax read-number
  (syntax-rules ()
    ((_ nums)
     (define-values nums
       (apply values (map string->number (string-split (read-line) #\space)))))))

(define-syntax read-numbers
  (syntax-rules ()
    ((_ as)
     (define as (map string->number (string-split (read-line) #\space))))
    ((_ as n)
     (define as (map (lambda (_) (map string->number (string-split (read-line) #\space))) (iota n))))))

(define-syntax prlist
  (syntax-rules ()
    ((_ lis)
     (print (string-join (map number->string lis) " ")))))

(define-syntax 1+ (syntax-rules () ((_ x) (+ x 1))))

(define-syntax 1- (syntax-rules () ((_ x) (- x 1))))

(define MOD 1000000007)

(define (rotate i s)
  (define l (string->list s))
  (list->string (append (drop l i) (take l i))))

(define (solve)
  (read-number (n k))
  (cond ((<= n (* k k))
	 (let1 m (x->integer (ceiling (sqrt n)))
	       (print m)
	       (let loop ((i m)
			  (n n))
		 (when (> i 0)
		   (let1 l (min m n)
			 (print (string-append (make-string l #\#)
					       (make-string (- m l) #\.)))
			 (loop (1- i) (- n l)))))))
	(else
	 (let1 m (ceiling (/ n k))
	       (print m)
	       (let loop ((i 0)
			  (n n))
		 (when (< i m)
		   (let1 l (min k n)
			 (print (rotate i (string-append (make-string l #\#)
							 (make-string (- m l) #\.))))
			 (loop (1+ i) (- n l)))))))))

(solve)
0