結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー Alex WiceAlex Wice
提出日時 2020-05-29 21:44:22
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 704 bytes
コンパイル時間 1,883 ms
コンパイル使用メモリ 76,448 KB
実行使用メモリ 79,616 KB
最終ジャッジ日時 2024-04-23 21:03:12
合計ジャッジ時間 4,883 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
77,340 KB
testcase_01 AC 85 ms
77,192 KB
testcase_02 AC 84 ms
77,708 KB
testcase_03 AC 87 ms
77,312 KB
testcase_04 AC 86 ms
77,568 KB
testcase_05 AC 86 ms
77,720 KB
testcase_06 AC 84 ms
77,464 KB
testcase_07 AC 86 ms
77,824 KB
testcase_08 AC 146 ms
79,608 KB
testcase_09 AC 88 ms
78,592 KB
testcase_10 AC 194 ms
79,388 KB
testcase_11 AC 120 ms
79,520 KB
testcase_12 AC 113 ms
79,360 KB
testcase_13 AC 117 ms
79,376 KB
testcase_14 AC 121 ms
79,252 KB
testcase_15 AC 163 ms
79,264 KB
testcase_16 AC 107 ms
79,360 KB
testcase_17 AC 111 ms
79,360 KB
testcase_18 AC 156 ms
79,616 KB
testcase_19 AC 121 ms
79,616 KB
testcase_20 AC 88 ms
78,720 KB
testcase_21 AC 143 ms
79,232 KB
testcase_22 AC 91 ms
78,268 KB
testcase_23 AC 87 ms
77,580 KB
testcase_24 AC 88 ms
77,596 KB
testcase_25 AC 195 ms
79,104 KB
testcase_26 AC 195 ms
79,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())

####
from collections import defaultdict as ddic
N,Q = rrm()
A = rrm()
queries = rrm()
MOD = 998244353
poly = [1]  # reverse order, MSB -> LSB
for a in A:
    a -= 1
    # multiply by x + a

    poly.append(0)
    for i in xrange(len(poly) - 2, -1, -1):
        poly[i+1] += a * poly[i]
        poly[i+1] %= MOD
    poly[0] %= MOD

for q in queries:
    print poly[~q]

    
0