結果

問題 No.883 ぬりえ
ユーザー 👑 KazunKazun
提出日時 2021-10-11 04:36:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 899 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 88,260 KB
最終ジャッジ日時 2023-10-13 03:27:48
合計ジャッジ時間 4,850 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,320 KB
testcase_01 AC 74 ms
71,412 KB
testcase_02 AC 72 ms
71,164 KB
testcase_03 AC 72 ms
71,160 KB
testcase_04 AC 73 ms
71,832 KB
testcase_05 AC 72 ms
71,692 KB
testcase_06 AC 75 ms
71,732 KB
testcase_07 WA -
testcase_08 AC 73 ms
71,320 KB
testcase_09 WA -
testcase_10 AC 73 ms
71,804 KB
testcase_11 AC 73 ms
71,776 KB
testcase_12 AC 77 ms
71,780 KB
testcase_13 AC 74 ms
71,964 KB
testcase_14 AC 81 ms
75,968 KB
testcase_15 AC 170 ms
88,260 KB
testcase_16 AC 107 ms
80,936 KB
testcase_17 AC 95 ms
78,840 KB
testcase_18 AC 78 ms
75,980 KB
testcase_19 AC 76 ms
71,492 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def Ceil_Root(a,k):
    """ceil(a^(1/k)) を求める.

    a:非負整数
    k:正の整数
    """
    assert 0<=a and 0<k
    if a==0:
        return 0
    if k==1:
        return a

    #大体の値を求める.
    x=int(pow(a,1/k))+1

    #増やす
    while pow(x,k)<a:
        x+=1

    #減らす
    while a<=pow(x-1,k):
        x-=1
    return x
#==================================================
N,K=map(int,input().split())

L=float("inf")
for m in range(1,K+1):
    q,r=divmod(N,m*m)
    s=Ceil_Root(r,2)

    if q*m+s<L:
        L=q*m+s
        M=m
        Q=q
        S=s

print(L)
X=[["."]*L for _ in range(L)]
for k in range(Q):
    for i in range(k*M, (k+1)*M):
        for j in range(k*M, (k+1)*M):
            X[i][j]="#"

R=N-Q*M*M
for i in range(Q*M,L):
    for j in range(Q*M,L):
        if R>0:
            R-=1
            X[i][j]="#"

for x in X:
    print(*x,sep="")
0