結果

問題 No.1742 Binary Indexed Train
ユーザー titiatitia
提出日時 2022-06-16 04:13:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,574 ms / 3,000 ms
コード長 426 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 82,508 KB
実行使用メモリ 79,744 KB
最終ジャッジ日時 2024-04-15 14:15:10
合計ジャッジ時間 20,894 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,584 KB
testcase_01 AC 39 ms
51,840 KB
testcase_02 AC 44 ms
57,600 KB
testcase_03 AC 1,466 ms
79,104 KB
testcase_04 AC 1,574 ms
79,744 KB
testcase_05 AC 1,553 ms
79,360 KB
testcase_06 AC 110 ms
76,416 KB
testcase_07 AC 133 ms
77,184 KB
testcase_08 AC 880 ms
78,728 KB
testcase_09 AC 871 ms
78,592 KB
testcase_10 AC 931 ms
79,616 KB
testcase_11 AC 872 ms
78,720 KB
testcase_12 AC 875 ms
78,976 KB
testcase_13 AC 1,435 ms
79,104 KB
testcase_14 AC 1,495 ms
79,360 KB
testcase_15 AC 142 ms
76,288 KB
testcase_16 AC 186 ms
76,388 KB
testcase_17 AC 212 ms
77,164 KB
testcase_18 AC 231 ms
76,928 KB
testcase_19 AC 128 ms
76,516 KB
testcase_20 AC 88 ms
76,672 KB
testcase_21 AC 141 ms
76,288 KB
testcase_22 AC 261 ms
76,928 KB
testcase_23 AC 106 ms
76,672 KB
testcase_24 AC 69 ms
72,064 KB
testcase_25 AC 443 ms
77,696 KB
testcase_26 AC 140 ms
76,668 KB
testcase_27 AC 371 ms
77,056 KB
testcase_28 AC 75 ms
76,288 KB
testcase_29 AC 319 ms
77,112 KB
testcase_30 AC 508 ms
77,056 KB
testcase_31 AC 1,363 ms
79,232 KB
testcase_32 AC 544 ms
77,516 KB
testcase_33 AC 251 ms
77,056 KB
testcase_34 AC 944 ms
78,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,Q=map(int,input().split())

for tests in range(Q):
    s,t=map(int,input().split())

    ANS=0

    while s<t:
        fb=N
        
        for i in range(N):
            if s & (1<<i) != 0 :
                fb=i
                break

        for i in range(fb,-1,-1):
            if s+(1<<i)<=t:
                ANS+=1
                s+=(1<<i)
                break

    print(ANS)
0