結果

問題 No.3 ビットすごろく
ユーザー mkawa2mkawa2
提出日時 2019-04-18 15:55:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 354 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 11,924 KB
実行使用メモリ 473,280 KB
最終ジャッジ日時 2023-10-22 08:16:20
合計ジャッジ時間 31,170 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
14,520 KB
testcase_01 AC 31 ms
10,172 KB
testcase_02 AC 29 ms
10,172 KB
testcase_03 AC 540 ms
46,724 KB
testcase_04 AC 81 ms
13,440 KB
testcase_05 AC 2,209 ms
149,400 KB
testcase_06 AC 635 ms
55,160 KB
testcase_07 AC 237 ms
21,360 KB
testcase_08 AC 1,367 ms
103,728 KB
testcase_09 AC 3,576 ms
243,648 KB
testcase_10 TLE -
testcase_11 AC 3,034 ms
186,576 KB
testcase_12 AC 2,081 ms
142,772 KB
testcase_13 AC 375 ms
34,800 KB
testcase_14 AC 4,574 ms
339,360 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
ps=set([1])
cnt=1
log=[]
while n not in ps:
    nps=set()
    for p in ps:
        dp=format(p,"b").count("1")
        if 0 < p + dp < n + 1:
            nps.add(p + dp)
        if 0 < p - dp < n + 1:
            nps.add(p - dp)
    if len(nps)==0 or nps in log:
        cnt=-1
        break
    log+=[nps]
    cnt+=1
    ps=nps
print(cnt)
0