結果

問題 No.688 E869120 and Constructing Array 2
ユーザー mitsuomitsuo
提出日時 2018-08-21 12:30:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 1,000 ms
コード長 781 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 10,864 KB
実行使用メモリ 7,928 KB
最終ジャッジ日時 2023-08-21 05:00:09
合計ジャッジ時間 1,566 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,876 KB
testcase_01 AC 15 ms
7,804 KB
testcase_02 AC 16 ms
7,824 KB
testcase_03 AC 16 ms
7,912 KB
testcase_04 AC 16 ms
7,800 KB
testcase_05 AC 16 ms
7,876 KB
testcase_06 AC 16 ms
7,928 KB
testcase_07 AC 16 ms
7,812 KB
testcase_08 AC 15 ms
7,880 KB
testcase_09 AC 16 ms
7,804 KB
testcase_10 AC 15 ms
7,920 KB
testcase_11 AC 15 ms
7,876 KB
testcase_12 AC 16 ms
7,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def combi2(c):
    return c * (c-1) / 2

def solve(N):
    if N == 0:
        return [1, "0"]

    p1set = {}
    count = 0
    for i in range(2, 31):
        p1set[int(combi2(i))] = count
        count += 1

    p2set = {}
    n = 1
    count = 0
    for i in range(1, 32):
        p2set[n] = count
        n *= 2
        count += 1

    zcount = 0
    for n, d in sorted(p2set.items(), reverse=True):
        if N % n == 0:
            N /= n
            zcount = d
            while(N not in p1set):
                N *= 2
                zcount -= 1
            if N in p1set:
                break

    onecount = p1set[N] + 2
    return [zcount + onecount, " ".join(["0"] * zcount + ["1"] * onecount)]

if __name__ == "__main__":
    [print(a) for a in solve(int(input()))]
0