結果

問題 No.1742 Binary Indexed Train
ユーザー mkawa2mkawa2
提出日時 2021-11-12 22:24:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 535 ms / 3,000 ms
コード長 944 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 78,952 KB
最終ジャッジ日時 2023-08-17 02:18:46
合計ジャッジ時間 11,682 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,584 KB
testcase_01 AC 68 ms
71,520 KB
testcase_02 AC 67 ms
71,204 KB
testcase_03 AC 502 ms
78,104 KB
testcase_04 AC 505 ms
78,044 KB
testcase_05 AC 501 ms
78,060 KB
testcase_06 AC 145 ms
78,952 KB
testcase_07 AC 145 ms
78,868 KB
testcase_08 AC 414 ms
78,288 KB
testcase_09 AC 435 ms
78,352 KB
testcase_10 AC 397 ms
78,464 KB
testcase_11 AC 437 ms
78,340 KB
testcase_12 AC 407 ms
78,280 KB
testcase_13 AC 489 ms
77,924 KB
testcase_14 AC 504 ms
78,004 KB
testcase_15 AC 125 ms
77,732 KB
testcase_16 AC 131 ms
77,660 KB
testcase_17 AC 175 ms
78,152 KB
testcase_18 AC 183 ms
78,184 KB
testcase_19 AC 124 ms
77,920 KB
testcase_20 AC 90 ms
76,828 KB
testcase_21 AC 126 ms
77,760 KB
testcase_22 AC 205 ms
78,184 KB
testcase_23 AC 92 ms
76,892 KB
testcase_24 AC 89 ms
77,208 KB
testcase_25 AC 250 ms
77,848 KB
testcase_26 AC 131 ms
78,008 KB
testcase_27 AC 209 ms
77,936 KB
testcase_28 AC 98 ms
77,608 KB
testcase_29 AC 214 ms
78,048 KB
testcase_30 AC 220 ms
77,732 KB
testcase_31 AC 535 ms
78,208 KB
testcase_32 AC 220 ms
77,652 KB
testcase_33 AC 135 ms
77,764 KB
testcase_34 AC 340 ms
77,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = 18446744073709551615
inf = 4294967295
# md = 10**9+7
md = 998244353

n, q = LI()
for _ in range(q):
    s, t = LI()
    if s == 0: lv = n
    else: lv = (s & -s).bit_length()-1
    ans = 0
    while s != t:
        while s+(1 << lv) > t: lv -= 1
        s += 1 << lv
        ans += 1
        # print(s,ans,lv)
        lv = (s & -s).bit_length()-1
    print(ans)
0