結果

問題 No.2344 (l+r)^2
ユーザー prussian_coderprussian_coder
提出日時 2023-06-11 08:58:17
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 553 bytes
コンパイル時間 437 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 152,704 KB
最終ジャッジ日時 2025-01-03 03:46:00
合計ジャッジ時間 12,988 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(input())

def rep_mul(a,x,m):
	t=0
	val=a
	while t<x:
		if val==0 or val==1:
			return val
		val*=a
		val%=m
		t+=1
	return val
	
def process(A,m):
	N=len(A)
	if N==1:
		return A[0]
	B=[(A[i]+A[i+1])**2%m for i in range(N-1)]
	return process(B,m)

def find_min_2x(N):
	return 1<<(len(bin(N))-3)
	

def solve():
	L,M=map(int,input().split())
	A=[int(x) for x in input().split()]
	m=1<<M
	while L>32:
		X = find_min_2x(L-30)
		A=[rep_mul(A[i],X,m)+rep_mul(A[i+X],X,m) for i in range(L-X)]
		L=len(A)

	print(process(A,m))
for _ in range(T):
	solve()
0