結果
問題 |
No.1068 #いろいろな色 / Red and Blue and more various colors (Hard)
|
ユーザー |
![]() |
提出日時 | 2020-05-30 03:13:40 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 917 bytes |
コンパイル時間 | 541 ms |
コンパイル使用メモリ | 82,288 KB |
実行使用メモリ | 87,552 KB |
最終ジャッジ日時 | 2024-11-06 18:33:06 |
合計ジャッジ時間 | 8,170 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 TLE * 1 -- * 18 |
ソースコード
P = 998244353 k = 4 K = k * 27 KK = 1 << K N, Q = map(int, input().split()) A = [1] * N + [KK + (int(a) - 1) % P for a in input().split()] pa1 = (1 << k * 18) - ((1 << k * 18) % P) pa2 = (1 << k * 12) - ((1 << k * 12) % P) pa3 = (1 << k * 8) - ((1 << k * 8) % P) def modP(x): x -= ((x & m1) >> k * 18) * pa1 x -= ((x & m2) >> k * 12) * pa2 x -= ((x & m3) >> k * 8) * pa3 return x for i in range(N)[::-1]: if i == N - 1 or i and 1 << i.bit_length() - 1 == i: if i == N - 1: c = 2 else: c *= 2 m1 = int(("1" * k * 9 + "0" * k * 18) * c, 2) m2 = int(("1" * k * 15 + "0" * k * 12) * c, 2) m3 = int(("1" * k * 19 + "0" * k * 8) * c, 2) A[i] = modP(A[2*i] * A[2*i+1]) t = bin(A[1])[2:] + "_" X = [int(t[-(i+1) * K - 1:-i * K - 1], 2) % P for i in range((len(t)+K-2) // K)] for a in [int(a) for a in input().split()]: print(X[a])