結果

問題 No.689 E869120 and Constructing Array 3
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-09 23:58:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 31 ms / 1,000 ms
コード長 1,005 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 11,884 KB
実行使用メモリ 10,360 KB
最終ジャッジ日時 2023-10-19 10:17:39
合計ジャッジ時間 1,996 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,344 KB
testcase_01 AC 30 ms
10,348 KB
testcase_02 AC 29 ms
10,348 KB
testcase_03 AC 30 ms
10,296 KB
testcase_04 AC 30 ms
10,356 KB
testcase_05 AC 30 ms
10,356 KB
testcase_06 AC 29 ms
10,288 KB
testcase_07 AC 29 ms
10,356 KB
testcase_08 AC 30 ms
10,356 KB
testcase_09 AC 31 ms
10,356 KB
testcase_10 AC 30 ms
10,356 KB
testcase_11 AC 30 ms
10,356 KB
testcase_12 AC 30 ms
10,360 KB
testcase_13 AC 30 ms
10,344 KB
testcase_14 AC 29 ms
10,344 KB
testcase_15 AC 30 ms
10,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main(K):
    if K == 0:
        print(1, 10, sep="\n")
        return
    elif K == 1:
        print(2, *[1, 1], sep="\n")
        return

    ok = False
    for i in range(1, int(K ** 0.5 + 0.5) + 1):
        if K % i == 0 and (i + K // i) <= 250:
            ok = True
            two, three = i, K // i
            break

    if ok:
        print(two + three)
        A = [3] * two + [8] * three
        print(*A)
        return

    one = 2
    while True:
        x = one * (one - 1) // 2
        ok = False
        if x > K:
            break
        tmp = K - x
        for i in range(1, int(tmp ** 0.5 + 0.5) + 1):
            if tmp % i == 0 and (one + i + tmp // i) <= 250:
                ok = True
                two, three = i, K // i
                break
        if ok:
            break
        one += 1

    if ok:
        print(one + two + three)
        A = [1] * one + [3] * two + [8] * three
        print(*A)
        return

    print(None)
    return


K = int(input())
main(K)
0