結果

問題 No.688 E869120 and Constructing Array 2
ユーザー Mr.FukuMr.Fuku
提出日時 2018-06-28 22:17:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 654 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 13,196 KB
最終ジャッジ日時 2023-09-21 20:57:39
合計ジャッジ時間 3,354 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
12,212 KB
testcase_01 AC 14 ms
7,752 KB
testcase_02 AC 14 ms
7,824 KB
testcase_03 AC 14 ms
7,764 KB
testcase_04 AC 15 ms
7,776 KB
testcase_05 AC 14 ms
7,836 KB
testcase_06 AC 14 ms
7,768 KB
testcase_07 AC 14 ms
7,760 KB
testcase_08 AC 15 ms
7,780 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!

k = int(input())
lst = []
n1,n2 = 1,2

for i in range(29):
    lst.append(n1*n2//2)
    n1,n2 = n2,n2+1

def white(n,zero,one):
    s = "0 "*zero+"1 "*one
    print(n)
    print(s[:-1])

def f():
    zero_pattern = 2
    zero_cnt = 1
    while True:
        yakusu = k//zero_pattern
        if yakusu in lst:
            one_cnt = lst.index(yakusu)+2
            total_cnt =zero_cnt+one_cnt
            if 30>=total_cnt:
                white(total_cnt,zero_cnt,one_cnt)
                return
        
        zero_pattern *= 2
        zero_cnt += 1

if k in lst:
    i = lst.index(k)+2
    white(i,0,i)
else:
    f()
0