結果

問題 No.1742 Binary Indexed Train
ユーザー dn6049949dn6049949
提出日時 2021-11-14 22:37:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 314 ms / 3,000 ms
コード長 865 bytes
コンパイル時間 1,067 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 80,792 KB
最終ジャッジ日時 2023-08-20 07:34:54
合計ジャッジ時間 12,611 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,876 KB
testcase_01 AC 92 ms
71,424 KB
testcase_02 AC 91 ms
71,872 KB
testcase_03 AC 247 ms
80,216 KB
testcase_04 AC 252 ms
80,400 KB
testcase_05 AC 250 ms
80,112 KB
testcase_06 AC 201 ms
80,792 KB
testcase_07 AC 202 ms
80,424 KB
testcase_08 AC 314 ms
80,492 KB
testcase_09 AC 292 ms
80,244 KB
testcase_10 AC 302 ms
80,280 KB
testcase_11 AC 308 ms
80,612 KB
testcase_12 AC 300 ms
80,228 KB
testcase_13 AC 202 ms
79,256 KB
testcase_14 AC 216 ms
79,092 KB
testcase_15 AC 176 ms
79,584 KB
testcase_16 AC 174 ms
79,528 KB
testcase_17 AC 232 ms
80,476 KB
testcase_18 AC 221 ms
79,908 KB
testcase_19 AC 187 ms
79,880 KB
testcase_20 AC 154 ms
79,252 KB
testcase_21 AC 184 ms
79,412 KB
testcase_22 AC 231 ms
79,904 KB
testcase_23 AC 159 ms
79,536 KB
testcase_24 AC 134 ms
77,968 KB
testcase_25 AC 227 ms
79,420 KB
testcase_26 AC 192 ms
79,616 KB
testcase_27 AC 217 ms
79,776 KB
testcase_28 AC 155 ms
78,924 KB
testcase_29 AC 230 ms
79,880 KB
testcase_30 AC 182 ms
79,716 KB
testcase_31 AC 233 ms
79,812 KB
testcase_32 AC 182 ms
79,712 KB
testcase_33 AC 158 ms
79,552 KB
testcase_34 AC 203 ms
79,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def main():
    def f(l,r):
        l += 2**n
        r += 2**n
        res = 0
        while l < r:
            if l & 1:
                res +=1
                l += 1

            if r & 1:
                r -= 1
                res += 1
            l >>= 1
            r >>= 1
        return res
    n,q = LI()
    for _ in range(q):
        l,r = LI()
        print(f(l,r))
    return


if __name__ == "__main__":
    main()
0