結果

問題 No.688 E869120 and Constructing Array 2
ユーザー htkbhtkb
提出日時 2018-05-19 11:20:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 1,000 ms
コード長 494 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 8,040 KB
最終ジャッジ日時 2023-09-21 20:31:30
合計ジャッジ時間 1,289 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,004 KB
testcase_01 AC 16 ms
7,936 KB
testcase_02 AC 17 ms
7,968 KB
testcase_03 AC 16 ms
7,932 KB
testcase_04 AC 16 ms
7,912 KB
testcase_05 AC 16 ms
8,040 KB
testcase_06 AC 16 ms
7,996 KB
testcase_07 AC 16 ms
8,008 KB
testcase_08 AC 17 ms
7,928 KB
testcase_09 AC 16 ms
7,912 KB
testcase_10 AC 17 ms
7,948 KB
testcase_11 AC 16 ms
7,932 KB
testcase_12 AC 16 ms
7,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import factorial
K = int(input())
result = [0] if K == 0 else [1, 1] if K == 1 else []
if not result:
    for i in range(2, 31):
        comb = factorial(i)//2//factorial(i-2)
        bin_k, bin_i = bin(K)[2:], bin(comb)[2:]
        if bin_k.startswith(bin_i):
            substr = bin_k[len(bin_i):]
            if "1" not in substr and i + len(substr) <= 30:
                result = [1]*i + [0]*len(substr)
                break
print(len(result))
print(" ".join(map(str, result)))
0