結果
| 問題 |
No.1742 Binary Indexed Train
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-07 18:54:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 675 bytes |
| コンパイル時間 | 399 ms |
| コンパイル使用メモリ | 82,348 KB |
| 実行使用メモリ | 78,628 KB |
| 最終ジャッジ日時 | 2024-09-27 19:29:37 |
| 合計ジャッジ時間 | 11,778 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 RE * 3 |
ソースコード
from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline
N,Q = map(int,input().split())
def solve(s,t):
S = []
T = []
for i in range(60):
if (s>>i)&1:
S.append(i)
if (t>>i)&1:
T.append(i)
if len(S) == 0:
return len(T)
while S[-1]==T[-1]:
S.pop()
T.pop()
if len(S)==0:
break
if len(S) == 0:
return len(T)
cost = T[-1] - S[0] - (len(S) - 1)
cost += (len(T)-1)
return cost
for _ in range(Q):
s,t = map(int,input().split())
print(solve(s,t),flush=True)