結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2017-09-24 20:39:03 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 736 bytes |
コンパイル時間 | 206 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-11-14 07:21:37 |
合計ジャッジ時間 | 2,542 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 15 |
ソースコード
def main(): N = int(input()) square = 1 ans = 1 s_f = set() s_b = set() while True: if square == N: print(ans) return # forward/backward n_b1 = bin(square).count("1") square_f = square + n_b1 square_b = square - n_b1 if square_f > N: s_f.add(square) if square_b <= 0: s_b.add(square) if square in s_f and square in s_b: print(-1) return if square not in s_f: s_f.add(square) square = square_f elif square not in s_b: s_b.add(square) square = square_b ans += 1 if __name__ == '__main__': main()