結果

問題 No.1742 Binary Indexed Train
コンテスト
ユーザー SPD_9X2
提出日時 2021-11-12 22:54:05
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 1,529 ms / 3,000 ms
+ 808µs
コード長 477 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 62 ms
コンパイル使用メモリ 81,708 KB
実行使用メモリ 112,904 KB
最終ジャッジ日時 2026-09-30 00:56:26
合計ジャッジ時間 25,634 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

"""

"""

import sys
from sys import stdin

def solve(a,b,l,r):
    
    if r <= a or b <= l:
        return 0

    if a <= l and r <= b:
        #print (l,r)
        return 1
    else:
        c1 = solve(a,b,l,(l+r)//2)
        c2 = solve(a,b,(l+r)//2,r)
        return c1 + c2

N,Q = map(int,stdin.readline().split())

ANS = []
for i in range(Q):

    S,T = map(int,stdin.readline().split())
    #T -= 1

    ANS.append( solve(S,T,0,2**N) )

print ("\n".join(map(str,ANS)))
0