結果

問題 No.3112 区間和係数多項式?
ユーザー 👑 p-adicp-adic
提出日時 2024-02-05 21:42:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 607 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 103,976 KB
最終ジャッジ日時 2024-02-05 21:43:03
合計ジャッジ時間 7,645 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,112 KB
testcase_01 AC 29 ms
10,112 KB
testcase_02 AC 28 ms
10,112 KB
testcase_03 AC 27 ms
10,112 KB
testcase_04 AC 28 ms
10,112 KB
testcase_05 AC 29 ms
10,112 KB
testcase_06 AC 30 ms
10,112 KB
testcase_07 AC 27 ms
10,112 KB
testcase_08 AC 28 ms
10,112 KB
testcase_09 AC 27 ms
10,112 KB
testcase_10 AC 27 ms
10,112 KB
testcase_11 AC 31 ms
10,240 KB
testcase_12 AC 29 ms
10,240 KB
testcase_13 AC 41 ms
10,368 KB
testcase_14 AC 61 ms
11,264 KB
testcase_15 AC 276 ms
11,264 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

R=range
J=lambda:map(int,input().split())
N,B,Q=J()
E,D=J()
A=[E]
for i in R(N-1):A+=[A[-1]*D%B]
P=1
while N-1>P:P*=2
T=[0]*P*2
for i in R(0,N-1):T[P|i]=A[i+1]
for j in R(P-1,0,-1):T[j]=(T[j*2]+T[j*2+1])%B
def G(l,r):
	l|=P
	r+=P+1
	a=b=0
	while l<r:
		if l&1:a,l=a+T[l],l+1
		if r&1:b,r=T[r-1]+a,r-1
		l,r=l>>1,r>>1
	return(a+b)%B
i,r=J()
i%=N
j,s=J()
x,t=J()
y,u=J()
for q in R(Q):
	k=P+i-1
	if i:
		T[k],k=x,k//2
		while k:T[k],k=(T[k*2]+T[k*2+1])%B,k//2
	else:E=(E+x-A[i])%B
	A[i]=x
	f=0
	p=1
	k=j%N
	while k:f,p,k=f+p*G(k-(k&-k),k-1),p*y%B,k-(k&-k)
	print((f+p*E)%B)
	i=i*r%N
	j=j*s%N
	x=x*t%B
	y=y*u%B
0