結果
| 問題 | No.3 ビットすごろく | 
| コンテスト | |
| ユーザー |  mkawa2 | 
| 提出日時 | 2019-04-18 15:55:37 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 354 bytes | 
| コンパイル時間 | 267 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 413,344 KB | 
| 最終ジャッジ日時 | 2024-09-22 09:16:08 | 
| 合計ジャッジ時間 | 33,841 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 13 TLE * 3 -- * 17 | 
ソースコード
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)
            
            
            
        