結果

問題 No.2393 Bit Grid Connected Component
ユーザー sepa38sepa38
提出日時 2023-07-28 21:30:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 394 ms / 2,000 ms
コード長 337 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 82,112 KB
実行使用メモリ 77,812 KB
最終ジャッジ日時 2024-10-06 17:42:32
合計ジャッジ時間 3,236 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
  x, y = map(int, input().split())
  if x & (1 << y) == 0:
    print(0)
    continue
  k = x | ((1 << y) - 1)
  ans = 1 << y
  for i in reversed(range(y)):
    if k & (1 << i) == 0:
      break
    ans += 1 << i
  for i in range(y+1, 60):
    if k & (1 << i) == 0:
      break
    ans += 1 << i
  print(ans)
0