結果

問題 No.3 ビットすごろく
ユーザー cyli
提出日時 2020-05-25 20:05:13
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 529 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-10-13 02:10:25
合計ジャッジ時間 2,062 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
a = []
for l in sys.stdin:
     a.append(l.rstrip('\n'))
# input 
if 0>int(a[0].split()[0]): 
    print(-1)
    exit()

num = 1
count = 1;
alreadyUsedNums = {0}
while True: 
  s = []
  zz = num
  if num in alreadyUsedNums:
      print(-1)
      exit()

  alreadyUsedNums.add(num)

  while True:
    s.append(int(zz%2))
    zz = zz/2
    if zz < 1: break

  num = num-s.count(1) if num + s.count(1) > int(a[0].split()[0]) else num+s.count(1)
  count += 1
  if num >= int(a[0].split()[0]): break

print(count)
#print(s)
0