結果

問題 No.1742 Binary Indexed Train
ユーザー Shirotsume
提出日時 2021-10-13 06:57:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,276 KB
実行使用メモリ 91,160 KB
最終ジャッジ日時 2024-11-25 10:53:38
合計ジャッジ時間 9,174 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(n, q, st):
    answer = []
    for s, t in st:
        ans = 0
        mid = 0
        for j in range(32, -1, -1):
            if not((s >> j) & 1) and (t >> j) & 1:
                    mid = 2 ** j * (s // (2 ** j)) + 2 ** j
                    break
        ans = bin(s).count('1') + bin(t).count('1')
        answer.append(ans)
    return answer


n, q = map(int,input().split())
st = [list(map(int,input().split())) for _ in range(q)]
answer = solve(n, q, st)

for i in answer:
    print(i)
0