結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2018-02-01 07:50:38 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 629 bytes |
コンパイル時間 | 210 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-12-30 01:45:56 |
合計ジャッジ時間 | 2,573 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 15 |
ソースコード
def count_one_of_binary(k): binary = bin(k)[2:] n_one = 0 for b in binary: if b == "1": n_one += 1 return n_one def calc_move_amount(current, goal, move): moved = current + move if moved <= goal: return moved else: return current - move def main(): current = 1 N = int(input()) reached = [] time = 1 while True: if current == N: print(time) return one_of_binary = count_one_of_binary(current) current = calc_move_amount(current, N, one_of_binary) if current in reached: print(-1) return reached.append(current) time += 1 main()