結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-17 15:55:45 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 370 bytes |
| 記録 | |
| コンパイル時間 | 534 ms |
| コンパイル使用メモリ | 20,956 KB |
| 実行使用メモリ | 28,924 KB |
| 最終ジャッジ日時 | 2026-04-02 14:27:19 |
| 合計ジャッジ時間 | 7,764 ms |
|
ジャッジサーバーID (参考情報) |
judge4_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 TLE * 1 -- * 29 |
ソースコード
def NX(a):
global N,K
K.append(a)
r=[]
b=bin(a).count("1")
if 0 < a-b and not a-b in K:r.append(a-b)
if N >= a+b and not a+b in K:r.append(a+b)
return(r)
N=int(input())
G=-1 if N!=1 else 1
buf=[[1,1]] if N!=1 else []
K=[]
while len(buf):
c,n=buf.pop(0)
for i in NX(n):
if i==N:
buf.clear()
G=c+1
buf.append([c+1,i])
print(G)