;;; 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 (solve) (read-number (n k)) (define-values (x y) (div-and-mod n (* k k))) (define-values (s l) (exact-integer-sqrt y)) (define m (+ s (if (> l 0) 1 0))) (print (+ (* x k) m)) (print (string-join (append (map (lambda (i) (string-join (map (lambda (_) (string-append (make-string (* i k) #\.) (make-string k #\#) (make-string (+ (* k (- x 1 i)) m) #\.))) (iota k)) "\n")) (iota x)) (map (lambda (_) (string-append (make-string (* x k) #\.) (make-string s #\#) (if (> l 0) #\. ""))) (iota s)) (map (lambda (_) (string-append (make-string (* x k) #\.) (make-string l #\#) (make-string (- s l) #\.))) (iota (if (> l 0) 1 0)))) "\n"))) (solve)