提出 #62135912


ソースコード 拡げる

t=int(input())



def solve():
  n,k=map(int,input().split())
  
  n_b = bin(n)[2:]
  left = n_b.count('0')
  if k>1<<left:
    print(-1)
    return
  k_b = bin(k-1)[2:]
  lk_b = list(k_b)
  ln_b = list(n_b)
#   print(ln_b )
#   print(lk_b)
  for i in range(len(n_b)-1,-1,-1):
    if ln_b[i]=='0':
      ln_b[i] = lk_b.pop() if lk_b else '0'
  new_n = int(''.join(ln_b),2)
  print(new_n)

for _ in range(t):
  solve()

提出情報

提出日時
問題 B - XOR = MOD
ユーザ decsp
言語 Python (PyPy 3.10-v7.3.12)
得点 500
コード長 441 Byte
結果 AC
実行時間 747 ms
メモリ 85072 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 1
AC × 29
セット名 テストケース
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 02_small_00.txt, 02_small_01.txt, 03_random_00.txt, 03_random_01.txt, 03_random_02.txt, 03_random_03.txt, 03_random_04.txt, 03_random_05.txt, 03_random_06.txt, 03_random_07.txt, 03_random_08.txt, 03_random_09.txt, 03_random_10.txt, 03_random_11.txt, 03_random_12.txt, 03_random_13.txt, 03_random_14.txt, 03_random_15.txt, 03_random_16.txt, 03_random_17.txt, 03_random_18.txt, 03_random_19.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 58 ms 76500 KiB
01_handmade_00.txt AC 137 ms 83556 KiB
01_handmade_01.txt AC 59 ms 76304 KiB
01_handmade_02.txt AC 437 ms 83360 KiB
01_handmade_03.txt AC 444 ms 83240 KiB
01_handmade_04.txt AC 744 ms 84988 KiB
01_handmade_05.txt AC 747 ms 85072 KiB
02_small_00.txt AC 567 ms 84416 KiB
02_small_01.txt AC 419 ms 83248 KiB
03_random_00.txt AC 456 ms 83048 KiB
03_random_01.txt AC 448 ms 83252 KiB
03_random_02.txt AC 455 ms 82920 KiB
03_random_03.txt AC 451 ms 82828 KiB
03_random_04.txt AC 451 ms 83232 KiB
03_random_05.txt AC 741 ms 84892 KiB
03_random_06.txt AC 743 ms 84828 KiB
03_random_07.txt AC 737 ms 85024 KiB
03_random_08.txt AC 741 ms 84912 KiB
03_random_09.txt AC 733 ms 84868 KiB
03_random_10.txt AC 453 ms 83348 KiB
03_random_11.txt AC 449 ms 83484 KiB
03_random_12.txt AC 451 ms 83240 KiB
03_random_13.txt AC 456 ms 83220 KiB
03_random_14.txt AC 458 ms 83568 KiB
03_random_15.txt AC 717 ms 84400 KiB
03_random_16.txt AC 725 ms 84776 KiB
03_random_17.txt AC 720 ms 84380 KiB
03_random_18.txt AC 718 ms 84448 KiB
03_random_19.txt AC 708 ms 84808 KiB