結果
問題 |
No.3 ビットすごろく
|
ユーザー |
![]() |
提出日時 | 2018-08-19 17:50:58 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 518 bytes |
コンパイル時間 | 178 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-11-17 18:27:32 |
合計ジャッジ時間 | 2,758 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 18 RE * 15 |
ソースコード
n=int(input()) lst = [0]*(n+1) def f(num,cnt): print(num,len(cnt)) if num==n: print(len(lst)) return True step = str(bin(num))[2:].count("1") fowd_n = num+step back_n = num-step if fowd_n<=n and fowd_n not in cnt: cnt.append(fowd_n) if f(fowd_n,cnt): return True if back_n>0 and back_n not in cnt: cnt.append(back_n) if f(back_n,cnt): return True return False if f(1,[1])==False: print(-1)