結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2017-12-09 02:12:33 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 543 bytes |
コンパイル時間 | 164 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-11-29 22:53:34 |
合計ジャッジ時間 | 2,389 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 WA * 16 |
ソースコード
def step(num): res = 0 if num in step.res_dict: return step.res_dict.get(num) while True: res += num % 2 num //= 2 if num == 0: break step.res_dict[num] = res return res step.res_dict = {} N = int(input()) m = 1 cnt = 0 while True: next = step(m) cnt += 1 if N < m + next: m -= next elif N > m + next: m += next else: m += next cnt += 1 print(cnt) break if cnt > N + N // 2: print(-1) break