結果

問題 No.2393 Bit Grid Connected Component
ユーザー ryohei22ryohei22
提出日時 2023-07-28 21:55:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 542 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 82,032 KB
実行使用メモリ 77,204 KB
最終ジャッジ日時 2024-04-16 05:48:28
合計ジャッジ時間 3,975 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,888 KB
testcase_01 AC 39 ms
53,560 KB
testcase_02 AC 40 ms
52,204 KB
testcase_03 AC 40 ms
53,692 KB
testcase_04 AC 40 ms
53,404 KB
testcase_05 AC 40 ms
52,408 KB
testcase_06 AC 41 ms
53,820 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 47 ms
60,888 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 511 ms
76,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
    x, y = map(int, input().split())

    if not x >> y & 1:
        print(0)
    elif y == 0 and (x - 1) % 4 == 0:
        print(1)
    elif ((x - 1) % 8 == 1 and y == 1) or ((x - 1) % 8 == 2 and y in [0, 1]):
        print(3)
    else:
        cnt = 0
        while 2**(cnt+1) <= x:
            cnt += 1
        cnt -= 2  # 何番目のピラミッドか
        s = 3 + cnt  # 各ピラミッドの一番下
        for i, j in enumerate(range(cnt+2, 0, -1)):
            s += j * 2**i
        print(s)
0