;;; 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)