結果

問題 No.1958 Bit Game
ユーザー pitPpitP
提出日時 2022-05-28 12:56:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,672 ms / 2,000 ms
コード長 1,089 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 81,764 KB
実行使用メモリ 143,332 KB
最終ジャッジ日時 2023-10-20 23:03:05
合計ジャッジ時間 39,259 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,591 ms
143,332 KB
testcase_01 AC 1,564 ms
142,956 KB
testcase_02 AC 1,625 ms
142,956 KB
testcase_03 AC 1,570 ms
142,952 KB
testcase_04 AC 1,606 ms
143,264 KB
testcase_05 AC 1,616 ms
142,960 KB
testcase_06 AC 1,644 ms
143,220 KB
testcase_07 AC 1,645 ms
142,952 KB
testcase_08 AC 1,657 ms
142,952 KB
testcase_09 AC 1,672 ms
142,956 KB
testcase_10 AC 587 ms
89,404 KB
testcase_11 AC 902 ms
106,040 KB
testcase_12 AC 759 ms
113,452 KB
testcase_13 AC 1,222 ms
106,472 KB
testcase_14 AC 1,185 ms
105,068 KB
testcase_15 AC 374 ms
109,916 KB
testcase_16 AC 241 ms
103,912 KB
testcase_17 AC 1,452 ms
113,688 KB
testcase_18 AC 1,124 ms
114,268 KB
testcase_19 AC 436 ms
110,888 KB
testcase_20 AC 1,551 ms
103,504 KB
testcase_21 AC 536 ms
114,352 KB
testcase_22 AC 937 ms
89,268 KB
testcase_23 AC 388 ms
101,552 KB
testcase_24 AC 1,531 ms
120,784 KB
testcase_25 AC 600 ms
104,648 KB
testcase_26 AC 1,447 ms
108,064 KB
testcase_27 AC 296 ms
106,300 KB
testcase_28 AC 1,584 ms
107,716 KB
testcase_29 AC 927 ms
98,868 KB
testcase_30 AC 38 ms
53,528 KB
testcase_31 AC 39 ms
58,928 KB
testcase_32 AC 77 ms
76,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def dot(A1,A2):
    # n:行列のサイズ
    l = len(A1)
    m = len(A1[0])
    m1 = len(A2)
    n = len(A2[0])
    if m != m1:
        print("CANNOT CALUCULATE!!")
        return
    A = [[0]*n for _ in range(l)]
    for i in range(l):
        for j in range(n):
            for k in range(m):
                A[i][j] += A1[i][k]*A2[k][j]
                A[i][j] %= mod
    return A

mod = 998244353
n,x,y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

cnta = [0] * 19
cntb = [0] * 19

for num in a:
    digit = 0
    while num:
        res = num%2
        cnta[digit] += res
        num //= 2
        digit += 1
    
for num in b:
    digit = 0
    while num:
        res = num%2
        cntb[digit] += res
        num //= 2
        digit += 1

ans = 0
for i in range(19):
    a1 = [[x-cnta[i],0],[cnta[i],x]] 
    b1 = [[y,y-cntb[i]],[0,cntb[i]]]
    A = [[1,0],[0,1]]
    A = dot(a1,A) 
    A = dot(b1,A) 
    B = [[1,0],[0,1]]
    for j in range(n):
        B = dot(A,B)
    ans += pow(2,i,mod) * B[1][0]
    ans %= mod

print(ans)
0