結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2017-07-22 15:14:53 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 774 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 29,480 KB |
最終ジャッジ日時 | 2024-10-09 09:52:58 |
合計ジャッジ時間 | 6,855 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 TLE * 1 -- * 29 |
ソースコード
N = int(input()) def wfs(): nowpos = {1:[1]} count = 1 while(True): count += 1 nextpos = {} for num in nowpos.keys(): progress = getBynum(num) if num + progress == N: return count elif (num + progress < N) & ((num + progress) not in nowpos[num]): nextpos[num + progress] = nowpos[num] + [num + progress] if num - progress == N: return count elif (num - progress > 1) & ((num - progress) not in nowpos[num]): nextpos[num - progress] = nowpos[num] + [num - progress] if(len(nextpos) == 0): return -1 nowpos = nextpos def getBynum(num): return bin(num)[2:].count('1') print(wfs())