結果

問題 No.2344 (l+r)^2
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2023-06-19 17:57:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 1,256 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 100,240 KB
最終ジャッジ日時 2023-09-09 13:23:49
合計ジャッジ時間 3,274 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,176 KB
testcase_01 AC 211 ms
94,668 KB
testcase_02 AC 155 ms
78,232 KB
testcase_03 AC 154 ms
77,880 KB
testcase_04 AC 152 ms
77,944 KB
testcase_05 AC 153 ms
78,012 KB
testcase_06 AC 149 ms
77,472 KB
testcase_07 AC 125 ms
87,312 KB
testcase_08 AC 129 ms
89,188 KB
testcase_09 AC 113 ms
85,012 KB
testcase_10 AC 120 ms
85,344 KB
testcase_11 AC 102 ms
81,072 KB
testcase_12 AC 195 ms
100,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

答えを見た

30段になるまでは、mod2でやってok

nCr mod 2 == 1 ⇔ n bitwizeOR r == n

"""

import sys
from sys import stdin


def nCr_Plane(n,r):
    if n < r or n < 0:
        return 0
    import math
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
    
def nCr_Lucas(n,r,mod):

    ret = 1
    while n > 0 and r > 0:
        ret = (ret * nCr_Plane(n % mod , r % mod)) % mod
        n //= mod
        r //= mod
    return ret


        
    

TT = int(stdin.readline())
ANS = []

for loop in range(TT):

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

    A = list(map(int,stdin.readline().split()))
    FOOT = 32

    if len(A) >= FOOT:

        a_tmp = []

        for slide in range(FOOT):

            #B = A[slide : slide + (N-FOOT+1)]

            #print (B)

            top = 0

            for i in range(N-FOOT+1):
                if A[i+slide] & 1 and (N-FOOT)|i == (N-FOOT):
                    top ^= 1 #(A[i+slide] % 2) * nCr_Lucas(N-FOOT,i,2)

            a_tmp.append(top)

        A = a_tmp

    mod = 2**M

    while len(A) > 1:
        B = []
        for i in range(len(A)-1):
            B.append( (A[i]+A[i+1])**2 % mod )
        A = B

    ANS.append(A[0] % mod)

print (*ANS,sep="\n")
0