結果
問題 |
No.1742 Binary Indexed Train
|
ユーザー |
👑 ![]() |
提出日時 | 2021-10-14 17:41:22 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 538 bytes |
コンパイル時間 | 151 ms |
コンパイル使用メモリ | 82,088 KB |
実行使用メモリ | 78,252 KB |
最終ジャッジ日時 | 2024-11-25 10:54:31 |
合計ジャッジ時間 | 8,054 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 16 WA * 16 |
ソースコード
popcount=lambda x:bin(x).count("1") def solve(S,T,N): l=0; r=1<<N while r-l>1: mid=(l+r)>>1 if T<=mid: r=mid elif mid<=S: l=mid else: break return popcount(mid-S)+popcount(T-mid) #================================================ import sys input=sys.stdin.readline write=sys.stdout.write N,Q=map(int,input().split()) Max=1<<N Ans=[0]*Q for quest in range(Q): S,T=map(int,input().split()) Ans[quest]=solve(S,T,N) write("\n".join(map(str,Ans)))