結果
問題 |
No.3 ビットすごろく
|
ユーザー |
![]() |
提出日時 | 2018-04-26 12:10:11 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 986 bytes |
コンパイル時間 | 92 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-06-27 21:08:25 |
合計ジャッジ時間 | 3,974 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 WA * 17 |
ソースコード
def Bit_sugorogu2(): N = int(input()) List = [] masu = 1 cnt = 1 while(True): List.append(masu) binary = bin(masu) num = binary.count("1") if(masu + num > N): break masu += num cnt += 1 if(masu == N): return cnt else: while(masu != 1): binary = bin(masu) num1 = binary.count("1") now_masu = masu - num1 cnt += 1 now_cnt = cnt while(True): if(now_masu in List): break List.append(now_masu) binary = bin(now_masu) num2 = binary.count("1") if(now_masu + num2 > N): break now_masu += num2 now_cnt += 1 if(now_masu == N): return now_cnt masu -= num1 return -1 print(Bit_sugorogu2())