結果
| 問題 | No.3 ビットすごろく | 
| コンテスト | |
| ユーザー |  compass19 | 
| 提出日時 | 2016-06-02 09:38:41 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 66 ms / 5,000 ms | 
| コード長 | 938 bytes | 
| コンパイル時間 | 130 ms | 
| コンパイル使用メモリ | 12,800 KB | 
| 実行使用メモリ | 11,904 KB | 
| 最終ジャッジ日時 | 2024-07-01 07:58:27 | 
| 合計ジャッジ時間 | 2,638 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 33 | 
ソースコード
N = int(input()) def step(num,k=0,result=0): while 2**k <= num: k = k + 1 while k != -1: if 2**k <= num: num = num-2**k result = result + 1 k = k-1 return result square, prev = [1], [-1] Hash = [[] for i in range(751)] Hash[1].append(1) def start(): global square, prev head, tail = 0, 1 while head < tail: now = square[head] s = step(now) if now-s > 0: if now-s not in Hash[(now-s)%751]: square.append(now-s) prev.append(head) Hash[(now-s)%751].append(now-s) tail = tail + 1 if now+s <= N: if now+s not in Hash[(now+s)%751]: square.append(now+s) prev.append(head) Hash[(now+s)%751].append(now+s) tail = tail + 1 if now+s == N: return True head = head + 1 return False def root(result=1): global square, prev k = prev[-1] while k != -1: result = result + 1 k = prev[k] print(result) if N == 1: print(1) else: if start(): root() else: print(-1)
