結果

問題 No.2393 Bit Grid Connected Component
ユーザー miya145592miya145592
提出日時 2023-07-28 21:49:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 715 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 87,296 KB
最終ジャッジ日時 2024-04-16 05:42:52
合計ジャッジ時間 2,836 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,484 KB
testcase_01 AC 39 ms
52,076 KB
testcase_02 AC 39 ms
52,544 KB
testcase_03 AC 38 ms
52,416 KB
testcase_04 AC 39 ms
52,744 KB
testcase_05 AC 38 ms
53,624 KB
testcase_06 AC 40 ms
53,300 KB
testcase_07 AC 38 ms
52,620 KB
testcase_08 AC 39 ms
52,376 KB
testcase_09 AC 39 ms
53,288 KB
testcase_10 AC 39 ms
52,656 KB
testcase_11 AC 39 ms
52,096 KB
testcase_12 AC 38 ms
52,888 KB
testcase_13 AC 44 ms
57,856 KB
testcase_14 AC 104 ms
76,952 KB
testcase_15 AC 114 ms
77,732 KB
testcase_16 AC 138 ms
79,476 KB
testcase_17 AC 223 ms
86,768 KB
testcase_18 AC 223 ms
87,012 KB
testcase_19 AC 215 ms
87,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
XY = [list(map(int, input().split())) for _ in range(T)]
for x, y in XY:
    ans = 0
    if x%4==0:
        r = y
        while (x>>(r+1))&1==1:
            r+=1
        now = 1<<r
        while now>0:
            ans+=now
            now//=2
        print(ans)
    elif x%4==1:
        if y==0:
            print(1)
        else:
            r = y
            while (x>>(r+1))&1==1:
                r+=1
            now = 1<<r
            while now>0:
                ans+=now
                now//=2
            print(ans)
    else:
        r = y
        while (x>>(r+1))&1==1:
            r+=1
        now = 1<<r
        while now>0:
            ans+=now
            now//=2
        print(ans)

0