11

# 测试用例

``````1
#
2
##
3
##
#
4
##
##
8
###
###
##
13
#####
#####
###
17
######
######
#####
18
#####
#####
#####
###
20
#####
#####
#####
#####
21
######
######
######
###
22
######
######
######
####
23
#####
#####
#####
#####
###
``````

6

# Pyth，28个字节

``````jbc*\#Qho.a,,N*NJ_/_QN,JQ_SQ
``````

``````(m - ceil(k/m))^2 + (m*ceil(k/m) - k)^2
``````

``````(m, m*ceil(k/m)) and (ceil(k/m), k)
``````

3

# Python 3，202个字节

``````k=int(input())
r,d,s=range(k+1),{},'#'*k
for n in r:
for m in r:
if m*n>=k:
d[m,n]=(m-n)**2+(m*n-k)**2
x,y=max(i for i in d.keys()if d[i]==min(d.values()))
[print(s[i*x:(i*x+x])for i in range(y+1)]
``````

Alex A.

Alex A.

`:`第5行缺少。逗号定义了一个元组，`()`第6行可以删除括号。`)`和（`if``for`）之间也有空格。`max`可以将生成器作为参数，因此括号`[]`是多余的。您可以遍历`d`键，因此可以放心使用`d[i]`

FlipTack

2

## CJam（44 42字节）

``````qi_,{)_2\$d\/m]_2\$-_*@@*2\$-_*+~}\$W=)'#@*/N*
``````

1

# CJam，42个字节

``````li:K_,f-{:XdK\/m]:YX-_*XY*K-_*+}\$0='#K*/N*
``````

``````li    Get and interpret input.
:K    Store in variable K for later use.
_     Copy.
,     Build sequence [0 .. K-1].
f-    Subtract from K, to get sequence [K .. 1]. Larger values have to come
first so that they are ahead in ties when we sort later.
{     Begin block for calculation of target function for sort.
:X    Store width in variable X.
d     Convert to double.
K\/   Calculate K/X.
m]    Ceiling.
:Y    Store height in variable Y.
X-    Calculate Y-X.
_*    Square it.
XY*   Calculate X*Y...
K-    ... and X*Y-K
_*    Square it.