結果
問題 | No.3112 区間和係数多項式? |
ユーザー | Shirotsume |
提出日時 | 2024-03-04 15:45:58 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,878 bytes |
コンパイル時間 | 373 ms |
コンパイル使用メモリ | 82,108 KB |
実行使用メモリ | 326,764 KB |
最終ジャッジ日時 | 2024-09-29 17:22:39 |
合計ジャッジ時間 | 9,855 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
53,640 KB |
testcase_01 | AC | 39 ms
54,276 KB |
testcase_02 | AC | 38 ms
53,876 KB |
testcase_03 | AC | 38 ms
52,944 KB |
testcase_04 | AC | 39 ms
53,228 KB |
testcase_05 | AC | 37 ms
52,860 KB |
testcase_06 | AC | 38 ms
53,376 KB |
testcase_07 | AC | 41 ms
54,120 KB |
testcase_08 | AC | 38 ms
54,076 KB |
testcase_09 | AC | 38 ms
52,560 KB |
testcase_10 | AC | 38 ms
53,064 KB |
testcase_11 | AC | 39 ms
55,228 KB |
testcase_12 | AC | 45 ms
60,400 KB |
testcase_13 | AC | 63 ms
72,108 KB |
testcase_14 | AC | 79 ms
76,192 KB |
testcase_15 | AC | 104 ms
76,828 KB |
testcase_16 | TLE | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
ソースコード
from __pypy__.builders import StringBuilder n, b, q = map(int, input().split()) c1, d1 = map(int, input().split()) c2, d2 = map(int, input().split()) c3, d3 = map(int, input().split()) c4, d4 = map(int, input().split()) c5, d5 = map(int, input().split()) import sys from os import read as os_read, write as os_write from atexit import register as atexist_register class Fastio: ibuf = bytes() pil = pir = 0 sb = StringBuilder() def load(self): self.ibuf = self.ibuf[self.pil:] self.ibuf += os_read(0, 131072) self.pil = 0; self.pir = len(self.ibuf) def flush(self): os_write(1, self.sb.build().encode()) def fastin(self): if self.pir - self.pil < 64: self.load() minus = x = 0 while self.ibuf[self.pil] < 45: self.pil += 1 if self.ibuf[self.pil] == 45: minus = 1; self.pil += 1 while self.ibuf[self.pil] >= 48: x = x * 10 + (self.ibuf[self.pil] & 15) self.pil += 1 if minus: return -x return x def fastin_string(self): if self.pir - self.pil < 64: self.load() while self.ibuf[self.pil] <= 32: self.pil += 1 res = bytearray() while self.ibuf[self.pil] > 32: if self.pir - self.pil < 64: self.load() res.append(self.ibuf[self.pil]) self.pil += 1 return res def fastout(self, x): self.sb.append(str(x)) def fastoutln(self, x): self.sb.append(str(x)); self.sb.append('\n') fastio = Fastio() rd = fastio.fastin; rds = fastio.fastin_string; wt = fastio.fastout; wtn = fastio.fastoutln; flush = fastio.flush atexist_register(flush) sys.stdin = None; sys.stdout = None class fenwick_tree(): n=1 data=[0 for i in range(n)] def __init__(self,N): self.n=N self.data=[0 for i in range(N)] def add(self,p,x): p+=1 while(p<=self.n): self.data[p-1]+=x p+=p& -p def sum(self,l,r): return self.sum0(r)-self.sum0(l) def sum0(self,r): s=0 while(r>0): s+=self.data[r-1] r-=r&-r return s a = [c1] for i in range(n - 1): a.append(a[-1] * d1 % b) A = fenwick_tree(n) for i in range(n): A.add(i, a[i]) def p(x): # the number of trailing zeros #x: int X = x if x==0: return 0 res=0 while(x%2==0): x//=2 res+=1 return X - 2 ** res P = [p(i) for i in range(n + 1)] def f(j, y): ans = 0 yy = 1 while j: ans += A.sum(P[j] + 1, j + 1) * yy ans %= b j = P[j] yy *= y yy %= b ans += yy * a[0] return ans % b i, j, x, y = c2 % n, c3 % n, c4 % b, c5 % b for _ in range(q): A.add(i, x - a[i]) a[i] = x wtn(f(j, y)) i *= d2 i %= n j *= d3 j %= n x *= d4 x %= b y *= d5 y %= b