結果

問題 No.688 E869120 and Constructing Array 2
ユーザー hang_hang_clnhang_hang_cln
提出日時 2018-06-09 10:09:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 19 ms / 1,000 ms
コード長 702 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 8,040 KB
最終ジャッジ日時 2023-09-21 20:51:13
合計ジャッジ時間 1,279 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
7,976 KB
testcase_01 AC 18 ms
7,972 KB
testcase_02 AC 19 ms
7,988 KB
testcase_03 AC 18 ms
8,040 KB
testcase_04 AC 17 ms
7,984 KB
testcase_05 AC 17 ms
7,908 KB
testcase_06 AC 17 ms
8,040 KB
testcase_07 AC 17 ms
7,944 KB
testcase_08 AC 19 ms
7,968 KB
testcase_09 AC 17 ms
7,904 KB
testcase_10 AC 17 ms
7,968 KB
testcase_11 AC 18 ms
8,024 KB
testcase_12 AC 19 ms
7,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def cb(n,k):
    return int(math.factorial(n) / math.factorial(k) / math.factorial(n-k))
    
def sumCB(n): # nC0 ~ nCnまでの合計
    return 2**n

def main():
    K = int(input())
    if K == 0:
        print(1)
        print(1)
    else:
        for n in range(2,31):
            for i in range(2,n+1): # i:1の個数
                if K % cb(i,2) == 0:
                    if cb(i,2) * sumCB(n-i) == K:
                        print(n)
                        b = '1' * i
                        b += '0' * (n-i)
                        print(' '.join(list(b)))
                        break
                else:
                    continue

if __name__ == '__main__':
    main()
0