結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
Mr.Fuku
|
| 提出日時 | 2018-06-24 21:38:04 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 553 bytes |
| コンパイル時間 | 99 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,520 KB |
| 最終ジャッジ日時 | 2024-06-30 22:35:29 |
| 合計ジャッジ時間 | 2,867 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 18 RE * 15 |
ソースコード
# coding: utf-8
# Your code here!
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)
Mr.Fuku